Wow. Thank you - that is very kind of you!
I have now done some testing with your code, on a PC with windows and an old iPad, both with different browsers. It's a bit confusing because there are so many combinations (devices/browsers). However, on the PC, another tab opens and quickly closes again, then the file download menu opens (so that is good, although it would be even better without the tab flickering).
On iPad, another tab opens and just shows the PDF, instead of showing the download-file-popup-window. The user may assume that the PDF has been downloaded and then closes the two tabs (and then the user will have no PDF file). Problem is also that none of the browsers I have tested on iPad shows the warning "Are you sure you want to quit the survey?" so it is easy for the user to lose the results there.
Do you have any suggestions how to change the just mentioned behavior? Also, no warning is shown on PC if users close their browser/tab, unless they scroll down a bit first. I wonder what has changed since the solution in the wiki no longer work. I don't think it is something special with my installation.
If you have time for another look - here is the code from my custom.js. I must have found it in this thread some time ago...
Code:
$(document).on('ready pjax:scriptcomplete',function(){
/**
* Code included inside this will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute
* @see https://learn.jquery.com/using-jquery-core/document-ready/
*/
});
//FEATURES: (2015-03-27) Now with fix for iframes (e.g. file uploader) and the template editor
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
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
//e.stopPropagation works in Firefox.
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
return 'Are you sure you want to quit this survey?'; // 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');
});
(window).on('beforeunload', function(){
var c=confirm();
if(c){
return true;
}
else
return false;
});