Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4034

IE11 file download triggers onBeforeUnload

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.6.1
    • 8.5.2
    • Browser Issue
    • Security Level: Jimmy
    • IE 11

    • ZK 8.6.0 S1, ZK 8.6.0 S2, ZK 8.6.1 S1

      Steps to Reproduce

      Run fiddle in IE11:
      http://zkfiddle.org/sample/1qah9ee/2-ie11-iframe-onbeforeunload-download

      trigger onBeforeunload by closing the current tab (or using ctrl+W)
      click file download button

      Current Result

      file download triggers onBeforeUnload message ("Are you sure you want to quit")

      Expected Result

      file download should not trigger this message

      Debug Info

      In pure html, IE 11 triggers onBeforeUnload event on the main window if an Iframe in the page puts a request and receive a file response with content-header "content-disposition:attachment"
      Can reproduce in pure html

      Root Cause

      IE11 wrongly triggers onBeforeUnload on main window when iframe content is changed

      Workaround

      • not perfect since if the server replies for longer than 1000ms, download will still trigger onBeforeUnload
      • Page can be closed without warning for 1000ms after receiving the download instruction
        <script><![CDATA[
        	zk.afterLoad('zul', function() {
        		var x = {};
        		zk.override(zAu.cmd0, x ,{
        			download : function() {
        				var sbu = zk.skipBfUnload;
        				zk.skipBfUnload = true;
        				var result = x.download.apply(this, arguments);
        				setTimeout(function(){zk.skipBfUnload = sbu;},1000);
        				return result;
        			}
        		});//zk.override
        	});//zk.afterLoad
        	]]></script> 
        

            rudyhuang rudyhuang
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 4 hours
                4h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours
                4h