如何检测IE中的窗口开启工具 [英] How do I detect window opener in IE
问题描述
我在堆栈上找不到任何好的答案 - 它们与对话框,文本编辑器以及一个使用VBScript的人有关。
I couldn't find any good answers on stack - they related to dialog boxes, text editors, and one guy used VBScript.
我需要发布消息开窗器。这在FF,Chrome和Opera中运行良好,但在IE8-10中 window.opener
为空。
I need to post a message to the window opener. This works fine in FF, Chrome and Opera, but window.opener
is null in IE8-10.
I我正在使用 window.open
来显示新窗口。
I am using window.open
to make the new window appear.
我甚至试过这个:
var new_window = window.open( url, '_social', "height=600,width=600" );
if ( !new_window.opener ) {
new_window.opener = window;
}
打开的窗口只有一个这样的脚本标记:
The opened window simply has a script tag like this:
<script type="text/javascript">
var data = {
type : 'redirect',
destination : '<?= $destination; ?>'
};
window.opener.postMessage( JSON.stringify( data ), '*' );
window.close();
</script>
我打开控制台并记录 window.opener
出现null,所以我认为它与DOM准备好之前没有任何关系。
I opened the console and logged window.opener
which comes up null, so I don't think it has anything to do with the DOM being ready or not.
窗口在登陆之前会重定向几次带有脚本标记的页面。
The window does redirect a few times before landing on the page with the script tag.
推荐答案
实际上,问题可能与window.opener无关 - 因为IE8 +可以只使用postMessage与iframe进行通信。
Actually, the problem may not have anything to do with window.opener – because IE8+ can only use postMessage to communciate with an iframe.
这篇关于如何检测IE中的窗口开启工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!