如何得到弹出式窗口的父窗口的句柄和焦点?

cookie2189 2003-08-27 10:04:55
如何得到弹出式窗口的父窗口的句柄和焦点?
...全文
98 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shyslysky 2003-08-27
  • 打赏
  • 举报
回复
parent.htm:

<body>
<br>
<br>
<br>
<INPUT id="t1" type="text" name="t1" value='我是父窗口!'>
<INPUT id="Button1" onclick='window.open("child.htm","","width=200,height=100")' type="button" value="打开" name="Button1">
</body>


child.htm:

<body>
<INPUT id="Button1" onclick ="opener.t1.focus();opener.t1.select();" type="button" value="父窗口获得焦点" name="Button1">
</body>
007james 2003-08-27
  • 打赏
  • 举报
回复
假设父窗口的form名字为father,里面有一个input名字为inp,子窗口form名字son,里面有一个input名字为inp_son,则在弹出式窗口中这样写就可以得到父窗口的句柄和焦点:

var obj = eval("window.opener.father.inp");
obj.focus(); //获取焦点
obj.value = document.son.inp_son.value; //取值
seabell 2003-08-27
  • 打赏
  • 举报
回复
opener.focus();
sw47 2003-08-27
  • 打赏
  • 举报
回复
this.opener
wind0209 2003-08-27
  • 打赏
  • 举报
回复
是opener吧

87,987

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧