工作,我需要打開一個彈出窗口,然後關閉後彈出窗口(刷新父頁)的JavaScript「beforeunload」事件不是在IE
jQuery的「beforeunload」事件在Internet Explorer 8中無法正常工作,9。
我的代碼是:
/*
* events
* add tallyman
*/
$("div.main form div.tallymanlist").click(function() {
if(gencargo.show_confirm('Add new tallyman?')) {
var windowObject = gencargo.windowOpener(600,1400, "Tallyman",$(this).children().attr("url"));
gencargo.windowParentRefresh(windowObject);
}
});
gencargo對象是內容(窗口打開):
/*
* open window
*/
windowOpener : function (windowHeight, windowWidth, windowName, windowUri) {
var centerWidth = (window.screen.width - windowWidth)/2;
var centerHeight = (window.screen.height - windowHeight)/2;
newWindow = window.open(windowUri, windowName, 'resizable=0,width=' + windowWidth +
',height=' + windowHeight +
',left=' + centerWidth +
',top=' + centerHeight);
newWindow.focus();
return newWindow;
},
,也窗口關閉:
windowParentRefresh : function(object) {
$(object).bind('beforeunload', function() {
object.opener.location.reload();
});
}
關閉窗口事件不工作即。只有在FireFox,Chrome,Opera。
是的。我試過了。但它仍然不工作,即ie – Dezigo
它似乎可以在IE 9上正常工作,但IE 8(IE 8在IE 8模式下)無法正常工作。 http://jsfiddle.net/DQfMH/ –