Согласно документации (я использую только Firefox ):
https://developer.mozilla.org/en/DOM/window.onunload
Событие unload вызывается, когда
документ выгружен.
Но мой код, приведенный ниже, вызовет предупреждение, даже если дочернее окно (то есть имя переменной "win") было только что открыто , а не закрыто.
alert("failed but still reload:" + win.isSuccess);
"failed but still reload: undefined"
Мое внимание заключается в том, чтобы вызывать эту загрузку, когда дочернее окно закрыто. Что я тут не так делаю ??
Код
function showInsertPopup() {
var ddId = document.getElementById("workRegionDropdown");
var index = ddId.selectedIndex;
var workRegionCode = ddId.options[index].value;
if(workRegionCode != "") {
var win = window.open(machineFormPopup + "?typeFlag=1&workRegionCode=" + workRegionCode, "window1", "menubar=no, width=700, height=550, toolbar=no");
win.onunload = function() {
if(win.isSuccess) {
alert("success reload!")
getRecordByWorkRegion();
}
else {
//here gets print out somehow
alert("failed but still reload:" + win.isSuccess);
getRecordByWorkRegion();
}
}//end inner function onunload
}
}//end showInsertPopup()
Страница дочернего окна содержит просто js:
window.isSuccess = 1;
window.close();