[web] Onclick TD link

Started by
2 comments, last by kbiro 18 years, 9 months ago
hey...here we go again. I'm just trying to get a <TD> tag to link to another page when you click anywhere inside the cell. I know this isn't right, but it's what I have so far:
<td onclick="href = 'http://www.spacelord/mother/mother.php';"> 
what am I doing wrong....err, how do I fix it? [smile]
Advertisement
Something like this should work:

<table>  <tr>    <a href="http://www.google.com"<td>google</td></a>  </tr></table>
Quote:Original post by Kalasjniekof
Something like this should work:

*** Source Snippet Removed ***


That's not valid xhtml (ignoring the typo). Two ways are:

<table>    <tr>        <td onclick="window.location='http://someplace.com';">Click Meh</td>    </tr>    <tr>        <td><a href="http://someplace.com" style="text-decoration: none; color: black;">Click Meh</a></td>    </tr></table>

[google]


p.s.

If the table cell is wider than the link, you can add "display: block; width: 100%;" to the style. Oddly enough Firefox only needs "display: block;" and IE only needs "width: 100%;" for that to work.

[Edited by - Ternary on June 28, 2005 1:48:22 PM]
wow, thanks guys!

This topic is closed to new replies.

Advertisement