简体   繁体   中英

How do I detect if a cross-domain popup or iframe finish loading?

I'm opening a new window of a different domain from the host. I want to start pushing URL fragments when it's done. I've tried this...

<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>

Credit: http://www.codingforums.com/archive/index.php/t-58396.html

But as the popup is cross-domain, the host cannot access windowReference.document .

Any other way around?

只需使用PostMessage进行跨域通信。

这是不可能的,因为您无法控制dom(文档),因此无法收听弹出窗口的任何事件。

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM