Skip to content Skip to sidebar Skip to footer

How To Check If A Js File Is Finished Loading?

I need to enable a button when a JS file is finished loading. The JS file which I am using is a builder from WebSphere Portlet Factory (WPF). How can I check if the JS file is fini

Solution 1:

How are you loading the file? If it's an ordinary <script> tag, the next Javascript file will not be run until all previous files have finished loading or died trying.

Other techniques (like $.ajax) have explicit provisions for completion callbacks.

Solution 2:

Use JQuery,

$(document).ready(function() {
  // Handler for .ready() called.
});

and Other way

// most browsers
scriptVar.onload = oCallback;

// IE 6 & 7
scriptVar.onreadystatechange = function() {
    if (this.readyState == 'complete') {
        oCallback();
    }
}

Post a Comment for "How To Check If A Js File Is Finished Loading?"