Questo codice funziona correttamente su Firefox, ma non riesco più a far funzionare l'evento di scarico su Chrome. Chrome ha smesso di supportare l'evento di scarico?Impossibile avviare l'evento di scaricamento in Chrome
Questo è il mio codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="../jquery/jquery.js"></script>
<script type="text/javascript">
function pageHidden(evt) { alert("Are you sure 1?"); } //WORKS ON FIREFOX BUT NOT IN CHROME
window.addEventListener("pagehide", pageHidden, false);
window.onunload = function() { alert("Are you sure 2?"); } //TRIGGERS ON LOAD NOT ON UNLOAD
$(window).unload(function() { //WORKS ON FIREFOX BUT NOT IN CHROME
alert("Are you sure 3?");
});
</script>
</head>
<body>
TEST WEBSITE
<a href="http://www.iamawesome.com">external link</a>
</body>
</html>
Come posso ottenere l'evento unload per lavorare in Chrome?
Grazie!
RISPOSTA: Non testare l'evento unload con avvisi;)
Possibile dupe: http://stackoverflow.com/questions/803887/can-i-pop-up-a-confirmation-dialog-when-the-user-is-closing-the-window-in-safari –
non stai attivando nulla da nessuna parte nel tuo codice. sei solo un gestore impegnativo. – jbabey
Controllare [questo bug report] (http://bugs.jquery.com/ticket/10509). In breve, non funzionerà in Chrome; prova ad usare invece il gestore '.onunload', ma anche quello potrebbe essere 'riparato'.) – raina77ow