问题
I have problem with onbeforeunload and preventing user from exit the page: When user want to exits i want to redirect him on other page, without any warning or pop-up
I try to popUp that page, but browser popup detect this and block it.
Is something like that possible?
Have a nice day!
回答1:
Browsers disallow that sort of behavior since it's normally a very unpleasant thing for the user.
回答2:
Yes, i know this is unpleasant, but it is mainly internal page, so it is targeted group of users ( i hate popups to). One way i found was just redirect user on other page with message "are you realy want to leave page" (of course he want if he go away, but this is some strange fSpec)
回答3:
You can use this code: window.onbeforeunload = function() { return "MyMessage"; }
来源:https://stackoverflow.com/questions/5182299/problems-with-onbeforeunload