...

View Full Version : Body onload alternative?



batric
05-18-2009, 11:28 PM
Hi,

Is there any alternative to the ' body onload="" ' function?

I have on the page several scripts running and one is blocking the others because of the body onload function.

It is working if I change that to body onfocus but it is loading the content all over when the user gets back to the page.

Any ideas how can I avoid this?

I can't apply onload to some element, onfocus is not working and this code also does not suite me:



<script type="text/javascript>
function();
</script>


Thanks in any case!

Batric

adios
05-18-2009, 11:37 PM
<script type="text/javascript">

function addListener(obj, evt, handler)
{
if (obj.addEventListener)
{
obj.addEventListener(evt, handler, false);
}
else if (obj.attachEvent)
{
obj.attachEvent('on' + evt, handler);
}
}

function init()
{
doSomething();
doSomethingElse();
makeThatThree();
}

addListener(window, 'load', init);

</script>

Also, could add all three separately.
btw it's window.onload, body tag or not.

batric
05-20-2009, 10:34 AM
Solved the issue - just added caller code to the bottom of the page (before closing body tag) and it works!

Thanks a lot in any case

netniks
01-08-2010, 05:14 AM
Please forgive me for asking what is likely obvious to everyone with programming bona fides,... I am looking for the html counterpart to the code above that Adios generously shared, so that I can include the following code (minus the "body window.onload", of course) into my html page.

<body window.onload="new Effect.Appear('one', { duration: 1.0, from: 0.0, to: 1.0, delay: 0.6 }); new Effect.Opacity('one', { queue: 'end', duration: 0.5, from: 1.0, to: 0.6, delay: 0.4 }); Effect.Appear('two', { duration: 1.0, from: 0.0, to: 1.0, delay: 1.4 }); new Effect.Opacity('two', { queue: 'end', duration: .5, from: 1.0, to: 0.6, delay: 0.4 }); Effect.Appear('three', { duration: 1.0, from: 0.0, to: 1.0, delay: 2.2 }); new Effect.Opacity('three', { queue: 'end', duration: 0.5, from: 1.0, to: 0.6, delay: 0.4 }); Effect.Appear('previous', { duration: 1.0, from: 0.0, to: 1.0, delay: 0.1 }); new Effect.Opacity('previous', { queue: 'end', duration: 0.5, from: 1.0, to: 0.4, delay: 0.1 }); Effect.Appear('next', { duration: 1.0, from: 0.0, to: 1.0, delay: 0 }); new Effect.Opacity('next', { queue: 'end', duration: 0.5, from: 1.0, to: 0.4, delay: 0 }); Effect.Appear('crown_logo', { duration: 1.0, from: 0.0, to: 0.8 }); return false;">

My website is supposed to display the fade in effect (using script.aculo.us and prototype, which can be seen here (http://userpages.bright.net/~toddw/orbit/aheader4.html)). I have recently added a drop-down menu, as well, but the above html will not work with the "window.onload" event present. see here (http://userpages.bright.net/~toddw/orbit/aheader.html).

Thanks and regards,
Todd



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum