Gossamer Forum
Home : General : Perl Programming :

TR as a link

Quote Reply
TR as a link
Hi

I've seen this done before on the web but can not remember where. What is the code I need to make a TR of a TABLE clickable? I want the entire row clickable. I've tried the obvious HREF which doesn't seem to work. I take it that I'm looking for some DHTML code?

Cheers

- wil
Quote Reply
Re: [Wil] TR as a link In reply to
How about using something like OnMouseDown in JavaScript?

--Philip
Links 2.0 moderator
Quote Reply
Re: [Wil] TR as a link In reply to
You could use onmousedown as Drew said but it looks ugly as the mouse pointer stays as a pointer so you could do something like:

Code:
<script language="javascript">
function go() {
location.href= "http://www.microsoft.com"
}
</script>

<table>
<tr onmousedown="go();" style="cursor:hand;">
<td>Foo</td><td>Bar</td>
</tr>
</table>

Last edited by:

RedRum: Jan 2, 2002, 11:48 AM
Quote Reply
Re: [RedRum] TR as a link In reply to
Couldn't I incorporate that into one Javascript call, instead of having to call another javascript sub routine? Maybe something like:

<tr onmousedown="go(location.href= "http://www.microsoft.com");" style="cursor:hand;">

Would that work? I am in no way a Javascript expert!

Thanks.


- wil
Quote Reply
Re: [Wil] TR as a link In reply to
You can indeed:

<tr onmousedown="javascript:location.href='http://www.microsoft.com';" style="cursor:hand;">





Last edited by:

RedRum: Jan 2, 2002, 12:02 PM
Quote Reply
Re: [Wil] TR as a link In reply to
google does it with it's advertisement links above the search results (when it does display it).
they use a onclick event on the tr (or maybe it was the td).
search something like auction and take a peek at their html.


Adrian
Quote Reply
Re: [brewt] TR as a link In reply to
Good point. I forgot about onclick. Hmm what actually is the difference between onmousedown and onclick?


Last edited by:

RedRum: Jan 2, 2002, 1:21 PM
Quote Reply
Re: [brewt] TR as a link In reply to
Google use a similar idea to my first example but in the td cell:

<script><!--
function c(o){location.href=document.all[o.id+"a"].href}
// -->
</script>

<td id=2 onClick="c(this)" style=cursor:hand; class=q bgcolor=#efefef width=60 nowrap>
Quote Reply
Re: TR as a link In reply to
Thank you all for your input. I'll give them all a whirl now!

- wil
Quote Reply
Re: [Wil] TR as a link In reply to
OK. I'm now using this:

Code:
OnClick="javascript:location.href='http://staff.fbagroup.co.uk/cgi-bin/index.cgi?action=fileman_browse;dir=$_;';" OnMouseOver="bgcolor:#ffffff;" style="cursor:hand;"

But for some reason, the background colour doesn't want to change. Anyone know how to fix this?

- wil
Quote Reply
Re: [Wil] TR as a link In reply to
Try background not bgcolor
Quote Reply
Re: [RedRum] TR as a link In reply to
Thanks for the suggestion; didn't work, though.

- wil
Quote Reply
Re: [Wil] TR as a link In reply to
Oh sorry I wasn't concerntrating, I thought you were using a style="" attribute.

Umm try:

<table>
<tr onMouseOver="this.bgColor='#FF3333';" onMouseOut="this.bgColor='#FFFFFF';" OnClick="javascript:location.href='http://staff.fbagroup.co.uk/cgi-bin/index.cgi?action=fileman_browse;dir=$_;';" style="cursor:hand;">
<td>La La La</td>
</tr>
</table>



Last edited by:

RedRum: Jan 3, 2002, 4:06 AM
Quote Reply
Re: [RedRum] TR as a link In reply to
Thanks. Still doesn't work - but this code produces no errors either ?

Maybe I should define some CSS styles and then reference them?

- wil
Quote Reply
Re: [Wil] TR as a link In reply to
It does work.

I was just playing with it about 5 minutes ago.
Quote Reply
Re: [RedRum] TR as a link In reply to
Hmm. Doesn't work on IE6, nor Mozilla .9.6?

- wil
Quote Reply
Re: [Wil] TR as a link In reply to
It must do - I use IE6

http://perlmad.com/test.html

That not work for you?
Quote Reply
Re: [Wil] TR as a link In reply to
By the way, should I not be blocked from accessing your Intranet?

...because I can kinda delete all your files and see all your client info Tongue

Last edited by:

RedRum: Jan 3, 2002, 4:34 AM
Quote Reply
Re: [RedRum] TR as a link In reply to
Yeah, but I'm testing so it's kinda open to the world at the moment :-)

- wil
Quote Reply
Re: [Wil] TR as a link In reply to
If you've got a minute; try it again! :-)

- wil
Quote Reply
Re: [Wil] TR as a link In reply to
Hmm. Hang on, you've just triggered my little brain into thinking something. Darn.

- wil
Quote Reply
Re: [Wil] TR as a link In reply to
Argh :-\

I can't get my head around the Authentication system now. It was just a case of authenticating you once when you logged on, now I've added it to check for authentication before loading any page - ugh, don't like the idea of how much time this will take.

But now it throws you back to the Authentication required page every time wherever you go. :-\

- wil
Quote Reply
Re: [Wil] TR as a link In reply to
This has also been suggested to me, Paul:

http://www.webmasters-forums.com/...=&threadid=16780

- wil