Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-05-2003, 03:14 PM
WebProWorld Member
 

Join Date: Aug 2003
Location: Seattle
Posts: 40
GooMoo RepRank 0
Default onload alternative

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.
Reply With Quote
  #2 (permalink)  
Old 09-05-2003, 06:27 PM
swstyles's Avatar
WebProWorld Pro
 

Join Date: Aug 2003
Location: Phoenix, AZ
Posts: 167
swstyles RepRank 0
Default

Its hard to believe that the onClick method would be blocked. Its used for so much more than pop up windows. There is a command for javascript to allow the page to load before any javascript gets processed. I forget what it is. What you can do is not call the function but process the preload at the footer of the page so preload is the last thing to happen.

Code:
<script>
preload code
</script
</body>
</html>
This is just a theory but it should work fine
__________________
Daniel M: South West Styles/STEELid
daniel@steelid.com
http://www.steelid.com
http://www.thephototool.com
Reply With Quote
  #3 (permalink)  
Old 09-05-2003, 09:45 PM
WebProWorld Member
 

Join Date: Aug 2003
Location: Seattle
Posts: 40
GooMoo RepRank 0
Default

Nah that wouldn't work, thanks though. The html and javascript is read and executed well before the graphics are even partially downloaded, that's why you can view source after the images start to load but before they are finished loading. A script fired onload goes after all html and graphics are loaded. i found it tough to swallow too but yes onclick is blocked by some popup blockers.
Reply With Quote
  #4 (permalink)  
Old 09-08-2003, 12:51 AM
WebProWorld New Member
 

Join Date: Sep 2003
Location: San Diego, CA
Posts: 4
orvadotech RepRank 0
Default Just use a normal function call

Just a thought...

If you place a "SCRIPT" block at the end of your page (before the close body or close html tag), you can call a javascript function which does all of the loading of the content. This should be equivalent to the "onLoad" event which is fired after all of the HTML has loaded.
__________________
Orvado Technologies http://www.orvado.com
Reply With Quote
  #5 (permalink)  
Old 09-08-2003, 10:12 AM
WebProWorld New Member
 

Join Date: Aug 2003
Location: IN
Posts: 8
mixdev RepRank 0
Default

orvadotech, this Technique is good for some specialised apps like my
http://www.amacement.com/senselabs/keyword_analyzer.php

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.

<SCRIPT language="JavaScript" src="openCode.js"></script>

and openCode has code like.....



function open_sisame(){
//code to do something on pageload follows
.............
.............
return 1;
}

// add the handler here
document.onload = open_sisame();



This would be enough to passthrough the nasty ad-block apps...i think
__________________
Webmaster Directory New!
Reply With Quote
  #6 (permalink)  
Old 09-08-2003, 12:41 PM
swstyles's Avatar
WebProWorld Pro
 

Join Date: Aug 2003
Location: Phoenix, AZ
Posts: 167
swstyles RepRank 0
Default

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.
__________________
Daniel M: South West Styles/STEELid
daniel@steelid.com
http://www.steelid.com
http://www.thephototool.com
Reply With Quote
  #7 (permalink)  
Old 02-28-2004, 03:53 AM
WebProWorld New Member
 

Join Date: Feb 2004
Location: Yucca Valley, CA
Posts: 12
johndodrill RepRank 0
Default

Even though I'm only a novice, I think I've tried all of those things only to find out that different browsers (Netscape, IE, Opera, Firefox, Mozilla) respond differently to onload="whatever" and windows.onload = 'whatever'; and they process JavaScript at different times with respect to HTML.

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:


function myFunction()
{
/* Clear the timer so you could use it again */
if (myTimerset == true)
{
clearTimeout(mytimerid);
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.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0