[Javascript] getElementsByTagName not working ???

James james at southspace.org
Thu Jul 21 07:25:27 CDT 2005


Hi,

this code doesn't work but I can't figure out what is wrong with it, it 
should be very simple, there are only 3 lines of script....

Thanks for any help.

James

SCRIPT

var all_links = document.getElementsByTagName('a');
var sitepoint_link = all_links[0];

// using our sitepoint_link variable from above
sitepoint_link.href = "http://www.google.com/";


/////////////////////////
HTML

<div id="codesection">
<p id="codepara">
</p>
<ul>
<li><a href="http://www.sitepoint.com/" id="splink">SitePoint</a></li>
<li><a href="http://www.yahoo.com/" id="yalink">Yahoo!</a></li>
</ul>
</div> 




More information about the Javascript mailing list