View Full Version : onload alternative
09-05-2003, 02:14 PM
i had previously used an onload script to load image rollovers and frames after the initial outside frame had loaded, but a recent test on a machine with a pop-up blocker showed that it prevents onload scripts. while i'm not using it for a popup, the frames targeted for load after the main page stayed in thier loading state. anyone know a way around this? i also noticed that some popup blockers will prevent onclick scripts, i had been using those to target multiple frames to new documents. can onclick also be avoided? i find popup blockers are becoming more and more popular and i'd like my sites to be viewable with them, specially when i don't even have popups.
09-05-2003, 05:27 PM
This is just a theory but it should work fine
09-05-2003, 08:45 PM
09-07-2003, 11:51 PM
Just a thought...
09-08-2003, 09:12 AM
orvadotech, this Technique is good for some specialised apps like my
this keyword analyzer is coded such a way that it will start processing ONLY after the form elements are loaded(using settimeout function).
But in this case it wont be good, because we want to load the imgs as soon as possible AND want to escape from adblockers. So as a solution for this, its good to use a external .js file having a document.onload handler code in it.
and openCode has code like.....
//code to do something on pageload follows
// add the handler here
document.onload = open_sisame();
This would be enough to passthrough the nasty ad-block apps...i think
09-08-2003, 11:41 AM
take your preload function code out of the function itself and your images will load as soon as the page is rendered up to that point in your code.
02-28-2004, 02:53 AM
So... I just estimate the first-time load time on the high side and use a timer.
Here's the meat of it (though I'm sure you already know this):
/* set up a timer with load time in milliseconds */
myTimerset = true;
mytimerid = window.setTimeout("myFunction()", 50000);
Then my function does this:
/* Clear the timer so you could use it again */
if (myTimerset == true)
myTimerset = false;
/* whatever afterload processing you want goes here, ie. */
document.images.myImage.src = "myImage.gif"
I hope this isn't too far astray of what you guys are trying to do.
It works for me on http://john.dodrill.name. I load all images as static images, to get the screen painted, then use a timer to load a rotating .gif at the top of the page.
On http://john.dodrill.name/socalemployers, I have to wait until all frames are loaded before I can start seting inter-frame variables, so I use this technique.
Hope this helps. By the way, these are all just my personal pages I'm toying with so don't look to be impressed.