简体   繁体   中英

load a page when close a popup page using “beforeunload”

I am trying to attach an event hanldler to beforeunload in javascript. Here is my code:

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

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

I get the alert but the loading div is not happen. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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