PDA

View Full Version : Hyperlink a div



Gangster
17-03-2008, 06:59 PM
well basically, im making a nav like HabbCrazy.net's, but inorder for the button to show, it needs to be hyperlinked, so i have to hyperlink the whole div if you know what i mean. would it be like this

<a href="..."><div class="style20" id="buttonid"></div><a>

rawritsluke
17-03-2008, 07:03 PM
Why don't you just make the button then do
<img src="urlll" />

Florx
17-03-2008, 07:20 PM
<div onclick="location.href='http://www.example.com';" style="cursor:pointer;">content</div>

For gods sake google it lol.

http://almosteffortless.com/2006/05/25/make-a-div-into-a-link/

[Oli]
17-03-2008, 07:25 PM
Yep, what florx said, thats how I do it, but as I have several divs to be linked I made a external .js file & made the functions in there, then I load in the js in the html (you know, <script language="javascript"> etc..) & then I just do <div class="name" onclick="linkfunction();">

Plux
17-03-2008, 07:34 PM
He's a lazy idiot who can't google.

Edited by jesus (Forum Super Moderator): Please do not insult other members.

Gangster
17-03-2008, 07:35 PM
He's a lazy idiot who can't google.
lol, Just because i didn't google, that makes me a lazy idiot. kk, lmao

Plux
17-03-2008, 07:36 PM
lol, Just because i didn't google, that makes me a lazy idiot. kk, lmao


You always post your crap here, it's easy to google a problem.
But you persist posting here? :S

Moh
17-03-2008, 07:46 PM
Why don't you just make the button then do
<img src="urlll" />
Because with divs you can use mouse overs. Well, just add a divname:hover into the css, much easier than javascript etc..

rawritsluke
17-03-2008, 09:07 PM
Because with divs you can use mouse overs. Well, just add a divname:hover into the css, much easier than javascript etc..
Ahh I didn't read that he wanted it on mouseover :)

Moh
17-03-2008, 09:09 PM
Ahh I didn't read that he wanted it on mouseover :)
He didnt, I was just giving a good example of why to use divs instead of image links :P

rawritsluke
17-03-2008, 09:10 PM
Oh right lmao.

Unpredictible.1
17-03-2008, 09:28 PM
He's a lazy idiot who can't google.

Edited by jesus (Forum Super Moderator): Please do not insult other members.

ey new username eh?

Edited by Hitman (Forum Moderator): Please don't post offtopic, thanks. :)

QuickScriptz
17-03-2008, 10:20 PM
You always post your crap here, it's easy to google a problem.
But you persist posting here? :S

Do we really need the negitivety? At first glance most people would instinctively try a link tag around a div. Obviously he tried this and it didn't give him the desired result so he went looking for a better way. Is it a crime to seek help in the 'Design & Development' from [some] knowledgeable members?

Jme
17-03-2008, 11:23 PM
Why don't you jsut use the a tag and set the button as the background and the display to block?


.button a
{
display: block;
height: ;
width: ;
background: url('path/to/image');
}

<a href="#" class="button"></a>

Want to hide these adverts? Register an account for free!