Reputation: 1055
I couldnt find anything that would get this same .vbs function done in javascript:
Do While browser.Busy
WScript.sleep 200
Loop
That waits until the browser is loaded to continue on with the script. "window.onLoad" was how to check if the browser is loaded in javascript, but I dont know any ways to have the script delay besides "setTimeout()"
So im wondering if theres any way to do it out there, and figured ide come here to find out :)
Thanks for any help!
Upvotes: 1
Views: 148
Reputation: 324620
// do some stuff
window.onload = function() {
// do more stuff when the page has finished loading.
}
Personally, I defer my scripts to right at the end of the page.
// start the page with:
loadScripts = [];
loadScript = function(cb) {loadScripts.push(cb);}
// end the page with:
while( x = loadScripts.shift()) x();
This is better than using onload
for two big reasons. First, it doesn't have to wait for massive images to be completely loaded. Second, I can call loadScript()
multiple times but you can only assign window.onload
once without overwriting it.
Upvotes: 2