我正在打開一個與主機不同的域的新窗口。 我想在完成後開始推送URL片段。 我已經試過這...如何檢測跨域彈出窗口或iframe是否完成加載?
<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
。
還有其他方法嗎?
這不適用於IE,即使是最新版本。 –