Forum Moderators: open

Message Too Old, No Replies

Making DIV link capable

I want to be able to click anywhere on the DIV

         

vincevincevince

8:13 pm on Jul 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm abusing DIVs to make nice pretty graphs using them as solid rectangles.

I'd like to be able to make them navigate on click, ie. as with <a href=....>

How can I do this?

killroy

11:17 pm on Jul 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Enclose them in a <a href

SN

TGecho

3:25 am on Jul 13, 2003 (gmt 0)

10+ Year Member



If you set display:block on an a tag, it'll act exactly like a div.

vincevincevince

7:42 am on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks :-)
enclosing in <a href didn't work - maybe because of absolute positioning? actualy only if i had content in the div did that become clickable.

final solution was onClick=location.href="blahblah"

zulaica

2:53 am on Aug 6, 2003 (gmt 0)

10+ Year Member



apparently onClick is invalid xhtml?! is there another way around this that will validate as xhtml 1.1 ... even if it's sloppy. i just need something to last until xhtml 2.0 let's us add href attributes to divs. ;)

setting it as an a with display:block won't work... i've got a span inside the div hiding an a from css-aware browsers. (say that 3 times fast *lol*)

thanks!

photon

1:23 pm on Aug 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try "onclick" instead--all lower case. Apparently XHTML likes the attributes to be in lower case. That error confused me also until I read about it somewhere on WebmasterWorld.

zulaica

7:26 pm on Aug 6, 2003 (gmt 0)

10+ Year Member



*ROFLMAO*

thanks so much, photon! i've got that in there for now, but i think i found a better solution to my problem... which ironically will involve me setting my <a> tag to display:block. i was just thinking about it the wrooooong way. guess that's what happens when you've been working on one tiny problem for 3 hours. *lol*

thanks again!