[Javascript] getElementsByTagName not working ???

Hassan Schroeder hassan at webtuitive.com
Thu Jul 21 07:52:56 CDT 2005


James wrote:

> 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....

> 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/";

Are you calling this *after* the page loads? Or at least after that
link exists?  :-)

-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the Javascript mailing list