19

Hi I have the following code to have few links on top of img. It works well in FF but not in IE. It seems IE is not clickable if you put link on top of img

<div style="z-index:-6755;"><img alt="October Offer" src="images/offers/october-offer.jpg" /></div>
<a href="javascript:void(0);" onclick="window.parent.SqueezeBox.close();" style="text-decoration: none; width: 147px; height: 32px; position: inherit; bottom: 32px; left: 50px; border: 1px solid red; display: block;" target="_parent"> </a> 

<a href="#" onclick="window.parent.SqueezeBox.close();">
<div style="display:block; width: 185px; height: 32px; position: relative; bottom: 50px; left: 260px;border:1px solid blue; ">&nbsp;</div>
</a>
4
  • I edited the code. It still doesn't make any sense, so feel free to go and have a look at the source if that makes more sense
    – Yi Jiang
    Sep 23, 2010 at 15:19
  • 1
    Your HTML code is broken. <href ... should be <a href... and links (<a>) are not allowed to contain block elements such as div s.
    – RoToRa
    Sep 23, 2010 at 15:22
  • 1
    href is not an element but an attribute Sep 23, 2010 at 15:23
  • @RoToRa @Mark That was my fault actually >< . The OP was using <aa> tags so that the parser won't render the code instead of displaying it (he didn't know how to use the code blocks) and I had pressed backspace twice instead of once, biting off that a there. I'm truly sorry for the confusion this has caused.
    – Yi Jiang
    Sep 23, 2010 at 15:30

2 Answers 2

36

are you just trying to make the image clickable?

you can't have <href> that's not a correct html tag.

either place <img> inside <a> like so: <a href="http://www.example.com/"><img /></a>

another way is to set a div with a background image of your image and then a link inside there, make the link display : block and make it the entire width and height of the div and the whole thing will be clickable.

0

You can add an on-click function to img-tag. Example: <img src="images/logo.png" alt="logo" onclick="home()">

and then redirect it to a page.

function home(){ location.replace("/index.html") }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.