Click to See Complete Forum and Search --> : newbie help needed, TD onclick to child A link


awx
04-13-2007, 01:20 AM
I'm trying to remove the last IE specific code from my site and get everything up to standard.

Here is a brief summary of my existing code (css classes removed, etc):
<TD onClick="this.children.tags('A')[0].click();">
<A id="TimelineLink" href="timeline.html">Timeline</A>
</TD>

In IE6, clicking on the cell/td will cause the browser to navigate to the link in the A tag. I want to accomplish the same thing but without actually specifying the URL in the TD element. This is because my site management tool will not manage URLs in JS code.

I've tried changing the onclick code to variations of this:
onClick="this.getElementsById('TimelineLink')[0].click();"
both with and without the [0] but nothing is working in FireFox. :(

What am I doing wrong?

gil davis
04-13-2007, 06:43 AM
onClick="this.getElementsById('TimelineLink')[0].click();"should be onclick="document.getElementById('TimelineLink').click();"
you should also be able to use onclick="location.href=document.getElementById('TimelineLink').href;"Hopefully you have not made the mistake of using 'TimelineLink' for more than one ID.

awx
04-13-2007, 05:06 PM
Thank you.
Is either the location or document solution preferred above the other? Any advantages or disadvantages to either one?

All of my IDs are unique.

gil davis
04-13-2007, 06:35 PM
I think that he one with location.href is easier for someone unfamiliar with the page to understand what you are trying to do.

awx
04-13-2007, 06:42 PM
That's a good point. As long as they are equally compatible then that does seem the better choice. Thanks