I implemented a sequential fade triggered by window.onload
I want to know if I can stop it from executing midway or wherever it currently is and show everything at once using ...style.display = "inline-block";
for everything that was going to be faded in.
If you have used,
function init()
{
}
window.onload = init;
Stop it!
That line of code will completely wipe out any other functions that were attached and ready to handle the onload
event. How arrogant of your script to do so! ;)
Instead, your script should learn to play nicely. Unfortunately, JavaScript doesn't support the delegate syntax that C#
has.
Yes, there is a way to achieve that :
function highlightXFNLinks()
{
// Does stuff...
}
//
// Adds event to window.onload without overwriting currently
// assigned onload functions.
function addLoadEvent(func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function')
{
window.onload = func;
}
else
{
window.onload = function()
{
oldonload();
func();
}
}
}
addLoadEvent(highlightXFNLinks);
window.onload += init;
Better than first one...
function AddOnload(myfunc)
{
if(window.addEventListener)
window.addEventListener('load', myfunc, false);
else if(window.attachEvent)
window.attachEvent('onload', myfunc);
}