我正在尝试在其父页面调用的子弹出窗口上侦听关闭事件。这个想法是让用户能够填写表格,然后使用弹出窗口接受权限并将视频上传到 YouTube。
我目前拥有的功能适用于 Chrome,但我似乎无法让它在 IE 8 上运行?
function ShowUploadVideoPopUp(URL){
//get the top and left position that the popup should be placed in
//half the screen width and height to center the popup
var top = Math.max(0, (($(window).height()) / 2) + $(window).scrollTop()) - 210;
var left = Math.max(0, (($(window).width()) / 2) + $(window).scrollLeft()) - 300;
//generate an id for this popup
day = new Date();
id = day.getTime();
//open the window
var win = window.open(URL, id, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=420,left = ' + left + ',top = ' + top);
//we need to set a timeout otherwise the unload event is called before the window is opened
//dont ask me why!?!
setTimeout(function(){
//add an event listener to listen for closure of the popup window
//call the video uploaded function when the window is closed
win.addEventListener("unload", VideoUploaded, false);
}, 500);
return false;
}
这个想法是,一旦弹出窗口关闭,我就可以在父页面上提交表单。
我得到的错误是:
'对象不支持此属性或方法'
我猜这意味着我分配创建的窗口不支持我调用 addEventListener 方法。
您对此的帮助将不胜感激。