On the page i'm creating there is a 3 columns table. Is it possible to make it so that if someone click anywhere in the first 2 cells of a row they get directed to a page and if they click anywhere in the 3rd cell they are directed to another one. I've tried playing a bit with the display in the css code but without finding how to achieve this effect.
Just use some simple Javascript and an onclick() to do this. If you want just one column to be clickable, put this inside the <td> tag. If you want the entire row to be clickable, put this inside the <tr> tag. If you were using it with a <td>, it would look like this:
You're welcome! You could also do some pretty cool stuff with that if you used some CSS. If you wanted any <td> that had an onclick attribute to be a different color, you could put this in your CSS:
Code:
td[onclick] {
background-color: #CCCCCC;
}
[note: the [] attribute selector doesn't work in IE6, so the user would have to have an updated browser to see what this code does.]
This CSS code would make it so that if you had any <td> tag linked with the onclick attribute, the background color of that cell would be #CCCCCC. Pretty cool, huh?
I tested JohnDubya's solution it's working but it's not exactly what i wanted.
1st the cell is not acting exaclty like a link. The cursor is not replaced by a small hand indicationg it's a clickable region. I could easely add some hover effect but i would like to have the cursor effect too.
2nd I'm not sure I want scripts in my page. The visitors of the page i'm creating will be far from being tech savy and for that reason I would prefer that they don't receive a message telling them that my page may be unsafe due to activeX scripts.
I heard that it is possible to surround a <tr> or <td> tag with an <a> tag to make the row or cell linkable. I haven't tested that, so I'm not for sure. I found the Javascript solution by Googling your question, so you can do the same, and you should find an answer. Good luck!
The cursor is not replaced by a small hand indicationg it's a clickable region. I could easely add some hover effect but i would like to have the cursor effect too.
Use CSS:
Code:
td:hover { cursor: pointer; } /* needs javascript (google "sfhover") to work in IE 6 */
Quote:
I would prefer that they don't receive a message telling them that my page may be unsafe due to activeX scripts.
A Javascript-powered event isn't the same as an ActiveX script; I doubt you'd get any warning (er, said the Mac user).
Location: Splendora, Texas, United States of America
Posts: 2,895
Thanks: 5
Thanked 187 Times in 184 Posts
Quote:
Originally Posted by JohnDubya
I heard that it is possible to surround a <tr> or <td> tag with an <a> tag to make the row or cell linkable.
That would be incorrect (X)HTML. You can’t nest table elements inside of anchor elements.
What you can do is put an anchor element inside a table cell and set its width and height equal to the size of the cell so that it creates the effect that the entire cell is clickable. There are some caveats though: the cell can’t have padding or content that isn’t inline-level. Example:
A Javascript-powered event isn't the same as an ActiveX script; I doubt you'd get any warning (er, said the Mac user).
Internet Explorer 7 disables JavaScript by default and produces a yellow bar at the top that must be clicked to activate scripts. It reads: “To help protect your security, Internet Explorer has restricted this webpage from running scripts or ActiveX controls that could access your computer. Click here for options…”. Of course, this only seems to apply to the My Computer zone (files from one’s own computer and not Web sites). Why Internet Explorer thinks files on one’s computer are more dangerous than those in the Internet zone escapes me.
__________________
Please for the love of god stop making IE. You current "browser"s cause me to cry every day. —Phil *