locked
setInterval on IE11 RRS feed

  • Question

  • User1510859543 posted

    We have a js function that opens a new window and then waits for that window to close and then open a different window.  It works perfect in Chrome and Edge but not IE11.  Below is the js we are using. It currently just keeps going and does not wait for 1st window to close.

            function openPDF() {
                var sro = document.getElementById('LblRepairOrderID').innerHTML;
                var surl = document.getElementById('txtPDFPath').value;
                var ssrswin = window.open(surl, '_blank', 'height=600,width=900,status=yes,toolbar=no,menubar=no,location=no,resizable=1');
                ssrswin.focus();
    
                var pollTimer = window.setInterval(
    	            function () {
    	                if (ssrswin.closed) {
                            var varRecordID = document.getElementById('txtRecordID').value;
    	                    window.clearInterval(pollTimer);
                            window.open('JobSetupReports.aspx?rid=' + varRecordID, '_blank');
    	                }
    	            }, 100);
    
            }

    Thursday, October 3, 2019 5:13 PM

All replies

  • User288213138 posted

    Hi dlchase,

    It works perfect in Chrome and Edge but not IE11.

    You run this code in IE11, you will get below error:

    The reason should be that you're trying to open a window in a different internet zone for which Protected Mode is enabled. By default, IE11 enables Protected Mode for the Internet and Restricted zones but disables it for Local Intranet and Trusted Sites.

    You can solve this problem by following the steps below:

    • Open IE > Tools > Internet Options
    • Go to Security Tab
    • Enable Protected Mode by clicking the checkbox
    • Restart IE

    Best regards,

    Sam

    Friday, October 4, 2019 8:28 AM
  • User1510859543 posted

    Tried that but did not work for me.

    Friday, October 4, 2019 8:06 PM
  • User-474980206 posted

    Unfortunately for you, IE unlike chrome and Firefox does not have a native pdf viewer. So when you load the pdf, control is passed to an separate viewer. This cause a navigate, so the original window is closed. Browser rules say that after navigation the window handle is invalid. 

    if the behavior is important, then rather than use an installed pdf viewer, use a JavaScript based viewer and you will have control.

    https://github.com/mozilla/pdf.js/

    Saturday, October 5, 2019 7:50 PM
  • User288213138 posted

    Hi dlchase,

    As Bruce said, IE does not have a native pdf viewer.

    But I found that the delay time you set in the window.setInterval() method is 100 milliseconds. Is this the cause of the problem?

    So I suggest you set the delay time a little longer to see the result.

    I tested in Chrome, Edge, IE11, and the results are delayed.

    Best regards,

    Sam

    Monday, October 14, 2019 2:58 AM