Welcome to WebmasterWorld Guest from 3.84.130.252

Forum Moderators: open

Message Too Old, No Replies

Simple IE window.onload alternative?

     
10:25 am on Jun 30, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 26, 2004
posts:3178
votes: 22


So window.onload doesn't work for squat in IE6...

I have a PHP file that renders (and is served as) the JavaScript which based on conditions (detected serverside) determine which functions are loaded in to the onload function...so if a function isn't needed then PHP won't echo that function name in to the master function. The master function is loaded via window.onload.

Anyway what is the simplest way or alternative to window.onload for IE without any other browsers to be considered for any possible issues? I know this sounds cheap but conditional comments allow it. ;)

- John

12:12 pm on June 30, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:May 29, 2007
posts:578
votes: 0


Apart from having to edit the body tag of every page... what's wrong with <body onLoad="myOnLoad();">... it works, I think, on all browsers/platforms
12:36 pm on June 30, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 26, 2004
posts:3178
votes: 22


I've tried that and IE 6 refuses to behave. Where do we go from here?

- John

JavaScript

function start() {
init28();
target();
init28ie();
}

XHTML

<body onload="start();">
1:36 pm on June 30, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:May 29, 2007
posts:578
votes: 0


Debug time?

Comment out ALL of the code in
init28();
target();
init28ie();

and simply have an alert in each function saying (for e.g.)

function init28(){
alert('init28 has fired');
/* all the other code commented out
...
...
*/
}

That will only take a few minutes and there's a high chance it will reveal if/where there is a bug

4:23 pm on June 30, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2004
posts:2047
votes: 0


So window.onload doesn't work for squat in IE6...

I agree. It's highly unlikely, John. I've never had a problem, and if this were the case, the whole scripting world would know about it by now.

The most common problem with assiging onload event is conflicts with others. Do you have another script that assigns a function to onload (presumeably aftwerards)?

It may be time to try attachEvent/adEventListener instead.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members