Solved

Links within a Table

Posted on 1998-10-20
8
137 Views
Last Modified: 2010-04-09
Is there a way to make an entire cell within a table, a link? Not just the text but the whole cell.
0
Comment
Question by:Skadfather
  • 5
  • 2
8 Comments
 
LVL 8

Accepted Solution

by:
jbirk earned 200 total points
ID: 1838901
Well, no, not really.  You could just use a normal link which started at the beginning and ended at the end of the table cell, but that would only link the elements within the cell, not the entire cell.

You could use some 4th generation event handling to grab the mouseclick and determine if it's in that table cell and then take some action if it is.  But this is pretty complicated and only works in netscape and IE 4+ browsers.  I'm not even totally sure that it will work with table cells, but I suppose it may be possible.  Probably more likely to work in IE 4 than netscape 4.

I'll look into this if you'd like, but I have a feeling it'll be a no go.
Sorry,
Josh
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1838902
If you want to pursue the event model you may be better off using layers.  I think it will work with layers like you want, but then you lose the table formatting...
-Josh
0
 

Author Comment

by:Skadfather
ID: 1838903
yeah i would rather not lose the Table format. and i would prefer to have most people able to use it (not limiting it to only those with IE4+ )
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 8

Expert Comment

by:jbirk
ID: 1838904
It was as I suspected.  It will work only in IE.  Here's a short example on how to do this in IE 4:
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>
<BODY>
<TABLE border=1><TR><TD>
Here is a table cell
<img src="cards_off.gif" width=200 height=50 border="0" name="Cards off">
</TD>
<TD id="testing">another table cell
<img src="cards_on.gif" width=200 height=50 border="0" name="Cards on">
</TD><TD>yet another table cell
<img src="Hdhp.gif" width=116 height=13 border="0" name="Hdhp">
</TD></TR></TABLE>
<SCRIPT language="JavaScript1.2">
<!-- cloak

var isIE = (navigator.appName.indexOf("Microsoft") != -1);

if (isIE)
 document.all.item('testing').onmousedown=handler;

function handler()
 {alert('You clicked inside the table cell!');
 }
// decloak -->
</SCRIPT>
</BODY>
</HTML>

Basically I had to use id to make a name for the second table element. Then it tells the browser to capture the mousedown event on that element, and then it calls the handler function when that occurs.

-Josh
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1838905
Sorry if this spoils any plans, but it simply won't work exactly as you want it to.  EIther it only works in IE 4 but does what you want exactly, or you need to use layers to get it to be more cross platform but won't work exactly as you want it to.

Sorry,
Josh
0
 

Author Comment

by:Skadfather
ID: 1838906
Too much trouble... and it wouldn't work on browsers other than IE4. would you mind if i kept the question open for a bit... if nobody else can give me an answer than ill grade it.
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1838907
Be my guest, but I really think that there is no other way to make an actual table cell link to something (other than the alternatives I mentioned)...

Note that if all that is in the table cell is an image you can just use a link around the image, but since you asked about the whole cell, I'm assuming you have more than just an image in the cell.

-Josh
0
 

Expert Comment

by:g2bam
ID: 1838908
The simple way of achieving this would be to make the table cell contain an image either blank or with the text for the link as part of the image. The background of the image could be transparent to match the rest of the table.

The image would then go between the normal <A HREF> tags. This would then present no problems in any browser and needs no scripts or anything else.

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question