We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,594 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Making image clickable inside a clickable div - hyperlinked

How can I get an image to have it's own hyperlink that is inside of a clickable div?

<div id="clickable" onclick="window.open('http://www.daniweb.com');return false;">

  <p>I love clickable images!</p>
    <a href="http://www.google.com"><img src="someimage.png" /></a>
  <p>too bad they don't click in a clickable div</p>

</div>

If I try the above then the DIV is always getting the click, never the image in the div. I can click the image, but the link for the div is what opens. Removing the return false does not help either.

2
Contributors
2
Replies
19 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
SolidSolutions
Junior Poster
136 posts since Jul 2010
Reputation Points: 24
Solved Threads: 24
Skill Endorsements: 0

try

<img src="img.jpg" onClick="window.open('http://www.daniweb.com')" />

i think it should work fine

baig772
Junior Poster
155 posts since Mar 2011
Reputation Points: 29
Solved Threads: 10
Skill Endorsements: 0

I thought I tried that one, but initial tests seem to be that it works.

Thanks!

SolidSolutions
Junior Poster
136 posts since Jul 2010
Reputation Points: 24
Solved Threads: 24
Skill Endorsements: 0
Question Answered as of 1 Year Ago by baig772

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0691 seconds using 2.71MB