跨IE窗体操作

跨IE窗体的操作有多种实现方法。

方法1、如果跨越的窗体是框架的,那么可以直接用框架的名称进行操作:
在我的 《ifream中的数据传递》 中提到过
不过如果是用框架集的话,需要使用到 frames 集合,并使用其索引来指定操作对象是哪一个窗体
如:top.frames[0].document.all.f1.value;

方法2、模态窗口的操作
通过获取模态窗口的返回值实现

主页窗口


 

<script>

function openmodel()
{
 var k;
 k=window.showModalDialog("model.htm");
 if(k!=null)
 {
 alert(k);
 }
 else
 {
 window.location.reload();
 }


}

</script>
<body>
<input type="button" value="打开模态" onClick="openmodel()">

</body>

模态窗口


<body>
<script>
window.returnValue='aa';
</script>
<input type="button" value="关闭" onClick="window.close();">
</body>

 

 

方法3、主窗口与被打开窗口的操作:
我在一个窗体1中用window.open打开一个新窗体2,我要在新窗体2的的按钮按下后,能把输入的信息传给窗体1使窗体1的页面更新,应该怎么做?

你试试下面的代码:
<input type=button value="刷新父窗口" οnclick="opener.reload();">


父窗口如下所示:
parent.htm
-------------
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Name</title>
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--">
<p>Name:<input type="text" name="name" size="20"><br>
Age:<input type="text" name="age" size="20"><input type="button" value="打开子窗口" name="B3" οnclick="window.open('children.htm','test');"></p>
</form>
</body>
</html>

 


子窗口如下所示:
children.htm
----------------
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Name</title>
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--">
<p>
Name:<input type="text" name="name" size="20"><br>
Age:<input type="text" name="age" size="20">
<input type="button" value="传给父窗口" name="B3" οnclick="opener.document.all.name.value=document.all.name.value;opener.document.all.age.value=document.all.age.value;"></p>
</form>
</body>
</html>
你可以根据你的需要适当的调整。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值