0
我想完成一些非常簡單的事情。 我指的是通過iframe的網站。禁用OnBeforeUnload事件:如何將Javascript發送到跨域Iframe?
iframe具有調用「onBeforeUnload」的函數。 我想在從我的父頁面卸載iframe之前關閉。
我已經想出瞭如何在同一個域上和同一頁上執行此操作。但是,我怎樣才能做到這一點跨域?
我會盡一切努力做到這一點,無論多複雜。
<iframe src="http://www.domain.com" width="100%" height="500" id="iframe"></iframe>
<script type="text/javascript">
$(document).ready(function() {
$('#iframe').load(function() {
alert('Load was performed.');
document.getElementById('iframe').contentWindow.window.onbeforeunload=null;
//NOTE: DOESN'T WORK CROSS DOMAIN!
});
window.onbeforeunload=null //Disables onbeforeunload event on THIS page so long as it is AFTER the original onbeforeunload event
});
</script>
謝謝!
所以沒有可能的方法就是你說的......甚至沒有一些瘋狂的鍛鍊腳本來覆蓋他們的onBeforeUnload,例如我自己在父頁面中?任何事情...... – 2010-12-07 18:44:07