Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Forrest, did you put your script at the top of the page ?
If so, this might be your problem.
Javascript is interpreted as the browser "sees" it.
If it's placed before HTML content, then it won't see any span, as they are not rendered at this time.
What you need is to launch your DOM parsing once the page is loaded
Code:
function initSpan(){
var temp = "";
var allSpans = document.getElementsByTagName("span");
for(var i = 0; i < allSpans.length; i++)
if(allSpans[i].class == "postmetadata") {
var catLinks = allSpans.getElementsByTagName("a");
for(var a = 0; a < catLinks.length; a++)
temp += catLinks[a].innerText + ", ";
}
window.status = "Categories: " + temp;
}
try{
window.addEventListener('load',initSpan, true);
}
catch(err){
window.attachEvent('onload',initSpan);
}
This makes the initSpan() function being called upon the onload event, and should resolve your problem.
It should be the same when you include js in an external file, it's maybe an coincidence if it works when you do so.
__________________
Only a biker knows why a dog sticks his head out the window.
|