How to create popup window when browser close
25,978
window.onUnLoad= function (evt) {
//your code goes here
window.open("yourpage/some link");
}
EDIT NOTE: Now it will be called on onUnload event of browser. Try now
Try window.onclose event:
https://developer.mozilla.org/en/DOM/window.onclose
How to capture the browser window close event?
References:
http://dotnetacademy.blogspot.com/2010/09/call-function-in-javascript-before.html
On below like you can find all events with example of window for javascript:
http://www.java2s.com/Tutorial/JavaScript/0380__Window/windowonUnLoad.htm
Author by
Pradeep Singh
Updated on November 24, 2020Comments
-
Pradeep Singh over 3 years
I want to open popup window when browser closed or closed tabs.
-
Pradeep Singh over 13 yearsthis function also called when page refresh that is the problem
-
Dr. Rajesh Rolen over 13 years@Pradeep: actually i created this function to ask user before closing browser that are u really want to close browser. let me modify it.