There are some actions which are not working in chrome, inside of the unload event. Alert or confirm boxes are such things.
But what is possible (AFAIK):
- Open popups (with window.open) - but this will just work, if the popup blocker is disabled for your site
- Return a simple string (in beforeunload event), which triggers a confirm box, which asks the user if s/he want to leave the page.
Example for #2:
$(window).on('beforeunload', function() {
return 'Your own message goes here...';
});
Demo: http://jsfiddle.net/PQz5k/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…