问题
I have jQuery open a popup:
function idealPopUp(str){
var url = str;
var windowName = "idealPopUp";
var windowSize = 'height=820,width=784,toolbar=no,scrollbars=yes';
window.open(url, windowName, windowSize);
event.preventDefault();
}
can I, from the original window, have jQuery target that popup? I want to know when it closes. The content of the popup is from another site and I have no control over it's jas/html etc.
I have this in the original window to try and talk to the popup:
$(document).ready(function(){
$('#idealPopUp').unload( function () {
alert("BING");
});
});
..
..
UPDATED FUNCTION:
function idealPopUp(url){
var windowName = "idealPopUpWindow";
var windowSize = 'height=820,width=704,toolbar=no,scrollbars=yes';
var idealPopUpWindow = window.open(url, windowName, windowSize);
$(idealPopUpWindow).unload( function () {
alert("BING");
});
event.preventDefault();
}
回答1:
var otherWindow = window.open(url, windowName, windowSize);
is a window reference; now you can
$(otherWindow).unload(...);
来源:https://stackoverflow.com/questions/8521728/jquery-target-different-window-popup