• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

Can I assign a hyperlink to an image loaded/positioned through a div tag?

I've created menu icons to run along the top of my website that I want to assign hyperlinks to.  In my index.php file I have <div id="div_home> to reference the follwoing from my css file.  How do I assign a hyperlink to this image?  Or, how do I assign positioning to the icon?  I can create a hyperlink to text and load an image with a hyperlink, but I don't know how to assign absolute positioning when doing this so I did it through the css file.  Help either way is appreciated.

#div_home{
position:relative;
top:6px;
left:14px;
height:78px;
width:40px;
display:block;
background-image:url(../images/Home.png);
background-repeat:no-repeat;
}
0
vsllc
Asked:
vsllc
  • 2
  • 2
1 Solution
 
OnthraxCommented:
you can attach an onclick event to the div itself.

You can already do this when craeting the html like this:

<div id="div_home" onclick="document.location='http://www.google.nl'"></div>

or do this through a bit of javascript like this:

document.getElementById("div_home").onclick = "document.location='http://www.google.nl'"

Hope this helps :)
0
 
vsllcAuthor Commented:
Thanks.  It works great.

One more quick question, is there a way to get the mouse to change from a pointer to hand when you scroll over the button?
0
 
OnthraxCommented:
Yes.. you can do this with the style element cursor.

e.g. style='cursor:pointer'

Hope this helps
0
 
vsllcAuthor Commented:
Thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now