Thanks a lot jonsen!
So I put in your code, but it didn´t really work. This is my function now:
Code:
function goodbye(e) {
if(!$('body', top.document).hasClass('submitted') && !$('#completed').length && !$('.templateeditor', top.document).length) { //check if a button was used to navigate OR the survey is completed OR the template is displayed in the template editor
//e.stopPropagation works in Firefox.
if (e.stopPropagation) {
alert('Please read the debriefing');
e.stopPropagation();
e.preventDefault();
}
return 'Are you sure you want to quit this survey?If you do, please make sure to read the DeBRIEFING Info'; // For chrome
}
}
window.onbeforeunload = goodbye;
$(document).on('click', '.button, .changelang, [name="move"]', function(event){ //added .changelang here, please add other classes if you know which should be allowed to navigate
$('body', top.document).addClass('submitted');
});
In Chrome, Message #2 is presented ("Are you sure you want to quit this survey?..."). IE displays both messages sequentially. In Firefox, there is no alert at all.
If I put in this snippet from the Workaround,
Code:
if(!e) e = window.event;
//e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = 'Are you sure you want to quit this survey?'; //This is displayed on the dialog for IE
Firefox displays its generic warning message.
Any ideas?
BTW: I am using Chrome Version 41.0.2272.118 m, IE 11.09600 and Firefox 37.0.1, these should all be the latest releases.
Thanks again cheers,
J.