如何检测跨域弹窗或 iframe 是否加载完成?
我正在打开一个与主机不同的域的新窗口。 我想在完成后开始推送 URL 片段。 我已经尝试过这个...
<script type="text/javascript">
<!--
function checkPage() {
if (windowReference.document.readyState == 'complete') {
alert('Done')
return;
}
setTimeout('checkPage()',100);
}
var windowReference = window.open('popup.htm','WindowName');
setTimeout('checkPage()',100);
//-->
</script>
信用:http://www.codingforums .com/archive/index.php/t-58396.html
但由于弹窗是跨域的,主机无法访问windowReference.document
。
还有其他办法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是不可能的,您无法控制 dom(文档),因此不可能监听弹出窗口的任何事件。
It's not possible, you do not have control over the dom (document), so it's not possible to listen to any events of the popup.
附加在主机窗口上的调整大小事件并通过弹出来更改宽度或高度 + 或 - 1 来触发调整大小怎么样?它可以在完全最大化的窗口上运行吗?
What about attaching on resize event on the host window and change width or height + or - 1 by from pop to trigger resize? Will it work on fully maximized window?
只需使用PostMessage进行跨域通信即可。
Just use PostMessage for cross-domain communication.