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

Posted on 2007-10-18
Last Modified: 2008-01-09
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.

Question by:vsllc
    LVL 13

    Accepted Solution

    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=''"></div>

    or do this through a bit of javascript like this:

    document.getElementById("div_home").onclick = "document.location=''"

    Hope this helps :)

    Author Comment

    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?
    LVL 13

    Expert Comment

    Yes.. you can do this with the style element cursor.

    e.g. style='cursor:pointer'

    Hope this helps

    Author Comment


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
    Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now