开发者

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;
}
s开发者_运维知识库etTimeout('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?


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.


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?


Just use PostMessage for cross-domain communication.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜