我试图在网页关闭的过程中触发一个事件。
方案是-一个网站打开一个单独的窗口,用户可以选择最小化。然后,这个最小化的页面等待用户关闭,或者在继续编写脚本之前完全离开主页导航。
我看过jQuery unload()方法,但我认为它不够具体,即它在任何类型的导航(刷新、菜单导航等)上都会触发。
是否可以使用此方法或另一种方法来实现此操作?
发布于 2015-01-12 18:41:59
这是不可能的,因为没有WINDOW_CLOSED事件,因为像浏览器主窗口一样显示的窗口对象属于底层操作系统的权限。即使在TDI(选项卡式文档接口) (如Microsoft的MDI在浏览器中实现)的情况下,在关闭选项卡时也不会触发任何事件。
发布于 2015-01-12 17:58:38
var winObj = null;var SixView =函数(a,b,c) { var popUpPageUrl = "../ViewDrawing.aspx?a=“+ $('id*=hdnAhuId').val() + "&compPosition=”+ spobtId + "§ionName=“+ c;winObj = myOpenWindow(popUpPageUrl,"myWin",winObj);}
function myOpenWindow(winURL, winName, winObj) {
var theWin; // this will hold our opened window
// first check to see if the window already exists
if (winObj != null) {
// the window has already been created, but did the user close it?
// if so, then reopen it. Otherwise make it the active window.
if (!winObj.closed) {
var result = confirm("Do you want to save the changes made in six view drawing ?");
if (result) {
saveChanges();
}
winObj = window.open(winURL, winName);
winObj.focus();
return winObj;
}
// otherwise fall through to the code below to re-open the window
}
// if we get here, then the window hasn't been created yet, or it
// was closed by the user.
theWin = window.open(winURL, winName);
return theWin;
}https://stackoverflow.com/questions/27907153
复制相似问题