Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

In IE 11 loading external scripts only load first item

SA-3519

Summary



A developer uses the jjquery.sessionTimeout.js functionality to load code to enable timed logouts for inactive users and to display warnings when sessions are about to time out.

The designed functionality works fine for Firefox, Chrome, Safari, IE up to 10. In IE 11 the initiation for the script does not actuate.
 
Originally it was beleived that the provided functionality WEBWB!PEGA_YUI_GET!JS in Pega-WB 07-10-01 doesn't iterate through list of resources as expected when loading external scripts. They were trying to load 4 java script URLs.
 
While investigation we observer that the even with one java script url it doesn’t work with IE11.


Error Messages



No errors are found in the Pega Logfile; no error messages are displayed on screen.

Steps to Reproduce



To reproduce this issue:

1. Configure the environment with the custom Java code.
2. Login to PRPC using the Microsoft Internet Explorer 11 browser
3. Wait for session timeout.
4. At timeout, notice that browser session still remains operational.

Root Cause



The jQuery sessionTimeout.js script utlizes the jQuery getScript instead of calling pega.util.Get.script.

Testing confirms that this code will work fine with MSIE browser versions prior to v11.

The code used was:

$.getScript("webwb/sessionTimeout.js").done(successScript).fail(failureScript);

The code should have been:

pega.util.Get.script(sURLs, {onSuccess: successScript, onFailure: failureScript});
 
Using the jQuery getScript method to call sessionTimeout.js will not be cached as this call appends a timestamp with every request:

http://wbhagsw7eu:8076/prweb/PRServlet/c6uXbf5xgDpAqRON1L1GXY-dUjpEeqFf*/webwb/sessionTimeout.js?_=1415781996089

Instead of:

http://wbhagsw7eu:8076/prweb/PRServlet/c6uXbf5xgDpAqRON1L1GXY-dUjpEeqFf*/webwb/sessionTimeout.js
 
And to cache it we will need to use an alternative solution to jQuery’s getscript function as described below.

Resolution



Below function gives you the same functionality of getScript, but you can now specify if the file is cached or not.

jQuery.loadScript = function (url, arg1, arg2) {
  var cache = false, callback = null;
  //arg1 and arg2 can be interchangable
  if ($.isFunction(arg1)){
    callback = arg1;
    cache = arg2 || cache;
  } else {
    cache = arg1 || cache;
    callback = arg2 || callback;
  }
               
  var load = true;
  //check all existing script tags in the page for the url
  jQuery('script[type="text/javascript"]')
    .each(function () { 
      return load = (url != $(this).attr('src')); 
    });
  if (load){
    //didn't find it in the page, so load it
    jQuery.ajax({
      type: 'GET',
      url: url,
      success: callback,
      dataType: 'script',
      cache: cache
    });
  } else {
    //already loaded so just call the callback
    if (jQuery.isFunction(callback)) {
      callback.call(this);
    };
  };
};


Another useful thing it does is check the existing page for the script you are trying to load. If it finds the script then it immediately calls the callback function.

Example Usage

Here is how you would use it with caching enabled:

$.loadScript('myscript.js', true, function() {
alert('I am loaded!');
});


The myscript.js file will now only get downloaded once. If the script was already included in the page header, then the script would never have been downloaded and the alert would have been shown immediately.

Also note that the function allows for the callback and caching parameters to be mixed around. The following 2 lines of code do exactly the same thing:

$.loadScript('myscript.js', true, callback);
$.loadScript('myscript.js', callback, true); 

Published January 31, 2016 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us