i have download button on application information page downloads pdf. have window.onbeforeunload event set pages start loading screen spinner , window.onunload event kills loading screen. problem i'm having when download pdf file, download works fine, window.onbeforeunload event fired , not window.onunload (as i'm not leaving page). causes loading page start when download file , never stop, making page appear hang on download.
i'm downloading systeminfo.pdf file using below htm , javascript:
<a href="#" onclick="systeminfo()">download system info</a> function systeminfo(){ var url = 'xxxxx/about/systeminfo?isajax=true'; window.location = formaturl(url); } i have attempted alter link use 'download' attribute not compatible safari , ie requirement along chrome , firefox. have added dynamic iframe fire change in have been told that's undesirable. please let me know if can help.
i've managed find way around feels smooth , not quite hacky adding iframe download in.
i created js variable (oldunloadvalue) outside systeminfo() function assign original function in window.onbeforeunload. set window.onbeforeunload separate function have created set window.onbeforeunoad it's original state. let's window.onbeforeunload fire no ill effect during file download resets functionality once download complete.
var oldunloadvalue; function systeminfo() { oldunloadvalue = window.onbeforeunload; window.onbeforeunload = resetonbeforeunload; var url = 'xxxxx/about/systeminfo?isajax=true'; window.location = formaturl(url); }; function resetonbeforeunload() { window.onbeforeunload = oldunloadvalue; }; doing things way has fixed problem still feels less ideal be.
Comments
Post a Comment