简体   繁体   English

使用“ beforeunload”关闭弹出页面时加载页面

[英]load a page when close a popup page using “beforeunload”

I am trying to attach an event hanldler to beforeunload in javascript. 我正在尝试将事件处理程序beforeunload到javascript中的beforeunload Here is my code: 这是我的代码:

$(window).on("beforeunload", function() {

    $("#popupin1").load("new.html");
})

I get the alert but the loading div is not happen. 我收到警报,但是没有加载div。 Is it possible to call a function on closing a page (popup page) in this way? 是否可以通过这种方式在关闭页面(弹出页面)时调用函数?

finally i got the answer .by done some change in this same code 最终我得到了答案。通过在同一代码中进行了一些更改

$(window).on("beforeunload", function() {

  window.opener.$("#popupin1").load("new.html");
}) 

also need 还需要

window.opener window.opener

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM