Every time I attempt to apply a function to window.onload... it seems to not work. It always fails. I think the reason is because the window is loaded before a lot of the things I'm trying to work with...
such as this...
Code: Select all
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}
addEvent(window, 'load', showLetter('A', 'show_category'));
'show_category' is a div that is supposed to be populated with html when the window loads... but that div isn't available at the time the window loads I guess... so what should I be using if not window.onload?