`
wx1569488408
  • 浏览: 79171 次
文章分类
社区版块
存档分类
最新评论

window.opener

 
阅读更多

opener 属性是一个可读可写的属性,可返回对创建该窗口的 Window 对象的引用。

opener 属性非常有用,创建的窗口可以引用创建它的窗口所定义的属性和函数。


在项目中,打开一个新的页面,但是新的页面要得到原有页面的参数并对原有页面部分的dom元素进行操作,即进行跨页操作。

用法:window.opener.$("#id")


说说javascript中几个内置对象的含义和使用方法。opener,self,parent

opener:对打开当前窗口的window对象的引用,如果当前窗口已被用户打开,则opener的值为null.

self:自引用属性,是对当前window对象的应用,与window属性同义.

self代表自身窗口,opener代表打开自身的那个窗口,比如窗口A打开窗口B.如果靠window.open方法,则对于窗口B,self代表B自己,而opener代表窗口A.

opener即谁打开我的,比如A页面利用window.open弹出了B页面窗口,那么A页面所在窗口就是B页面的
opener,在B页面通过opener对象可以访问A页面。
parent表示父窗口,比如一个A页面利用iframe或frame调用B页面,那么A页面所在窗口就是B页面的parent。


document.referrer:referrer 属性可返回载入当前文档的文档的 URL。


转载于:https://my.oschina.net/u/2449014/blog/537078

分享到:
评论

相关推荐

    字符串 window.open() window.opener window.name window对象等的总结

    本篇文章将深入探讨`window.open()`、`window.opener`、`window.name`以及`window`对象的一些核心概念,同时通过两个带有注释的页面示例(001.html和main.html)帮助理解这些知识点。 ### `window.open()` `window...

    通过window.opener控制父窗体

    在发送窗口(子窗口)中,使用`window.opener.postMessage(data, targetOrigin)`发送消息,其中`data`是你要传递的数据,`targetOrigin`是接收窗口的源。在接收窗口(父窗口)中,需要添加事件监听器: ```...

    解决window.opener=null;window.close(),只支持IE6不支持IE7,IE8的问题

    本文将深入探讨一个这样的问题:`window.opener = null; window.close()` 这段代码在IE6中能够正常工作,但在IE7及更高版本中却失效的问题。 `window.opener` 是JavaScript中的一个属性,它引用了创建当前窗口的...

    window.opener用法和用途实例介绍

    window.opener.document.getElementById('orgNameId').value = name; window.close(); // 关闭子窗口 } } ``` 在上面的 `selectOrg` 函数中,当用户在子窗口中选择一个机构后,它会找到父窗口中的 `orgIdId` 和 ...

    js关闭浏览器窗口及检查浏览器关闭事件

    [removed] function closeWin(){ window.opener=null; window.open(”,’_self’,”); window.close(); } [removed] <a>logout</a> </body> </html> 火狐默认不支持js关闭浏览器窗口,可以在about:...

    JS window.opener返回父页面的应用

    window.opener.location.href = url; // 关闭当前的支付窗口 window.close(); } ``` 在实际应用中,需要注意跨域安全问题。由于同源策略的限制,`window.opener`在不同源之间可能无法正常工作。如果支付页面和...

    用window.open,opener实现网页间通信

    var txt = window.opener.document.getElementById("msg"); txt.value = "secondsaysyouwelcome"; }); } function secondcall(msg) { if (msg.indexOf("third") > 0) { tw = window.open("third.html", ...

    js弹窗并返回值(window.open方式)

    window.opener.result = result; window.close(); } // 用户在b.html操作后调用sendResultAndClose sendResultAndClose('用户的选择'); // 在原窗口监听新窗口关闭事件 window.addEventListener('message', ...

    window.showModalDialog以及window.open用法简介

    window.opener.document.getElementById("name").value = "输入的数据"; ``` 这会将新窗口中的数据赋值给父窗口ID为"name"的文本框。 接下来,`window.showModalDialog`是Internet Explorer 4及以上版本引入的方法...

    window.location.href页面跳转的用法(区别于redirect)

    window.opener.document.location.reload(); ``` #### 总结 通过本文的介绍,我们可以看到`window.location.href`不仅能够实现简单的页面跳转,还能灵活地应用于复杂框架结构中的页面跳转及刷新。相比`Response....

    showModalDialog open弹出子窗口操作parent、opener父窗口及跨域处理

    opener.parentObj.elementObj.arrtr = 'str'; 3> IE与FireFox对两个弹出窗口在跨域时的解析也有不同:通过window.dialogArguments操作父窗口时,在IE下不需要指定document.domain而在FireFox下则正好相反需要指定...

    Javascript中封装window.open解决不兼容问题

    对window.open进行封装, 使其更好用, 且更兼容, 很多人说window.open不兼容,其实不是, 因为不能直接执行, 必须通过用户手动触发才行;看代码: 代码如下 var openWindow = function(url, options) { var str = ""; ...

    jsp 刷新父页面

    window.opener.location.href = window.opener.location.href 刷新以winodw.showModelDialog()方法打开的窗口 window.parent.dialogArguments.document.execCommand('Refresh'); 或 Response.Write("<script>...

Global site tag (gtag.js) - Google Analytics