Reputation: 1735
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 finished loading so that I can enable the button?
Upvotes: 0
Views: 1147
Reputation: 18064
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();
}
}
Upvotes: 0
Reputation: 44386
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.
Upvotes: 2