Is there any way to different if a popup window is closed by window.close()
or closed by mouse click? I want to different if user manually closed the popup or not.
CodePudding user response:
I can't understand what are you trying to say. describe properly please.
CodePudding user response:
check-in close event listener if the user clicks a close button then you get data and you know the user clicks manually otherwise not.
CodePudding user response:
You need to bind the onbeforeunload event to the window AFTER it is opened.
The simplest way to do that would be to have the javascript onbeforeunload code within the window source code.
var pop_up_window = window.open('some url')
pop_up_window.onbeforeunload = function(){ /* your code */ }
Please check following for more details
https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event