I am having trouble with my onload code running seemingly before the page has loaded. I thought onload was supposed to run once the page had finished loading?? For example,
[CODE]window.onload = countAnchors();
function countAnchors() {
var anchors = document.getElementsByTagName(‘a’);
var numA = anchors.length;
alert(numA);
}
I get 0 when I refresh the page, but 42 when I click a link which runs countAnchors(), as there are actually 42 <a> elements on the page.
Maybe I am wrong in expecting it to wait for the page… I am new to this. If this is working correctly, can you tell me how I can run some code AFTER the page has loaded?
Thanks for any help.
Grape