+ 9

How can I add a clickable image?

What can I do to make the image I put, be able to redirect someone to a different webpage if the user clicks it?

20th Jan 2017, 6:00 AM
Miguel Nunez-Ramirez
Miguel Nunez-Ramirez - avatar
15 Answers
+ 35
<a href= "link where you want to redirect the user"><img = "link to the image" alt= "sentence you want to say if the image isn't loading" /> </a>
20th Jan 2017, 6:02 AM
Miguel Nunez-Ramirez
Miguel Nunez-Ramirez - avatar
+ 19
<img src="myImage.jpg" onclick="location.href = 'http://www.google.com'">
20th Jan 2017, 6:19 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 5
You just have to create a link <a> with an image in it like this : <a href="#"><img src=""></a>
21st Jan 2017, 6:21 PM
Ninja Nudiste
Ninja Nudiste - avatar
+ 2
@Ninja - Using # in an anchor is an in-page redirect; OP wants a different webpage. Note for others: One of the main issues with images inside anchors is that anchors apply additional formatting and behavior. This will require you to fiddle with block/border/inline CSS depending on your preferences (you may not care about presentation/quirks, just be aware that CSS can help resolve problems--or be the source of them if you include someone else's stylesheets).For <a><img ... you should also specify width and height so the preprocessor can get on with rendering the DOM and not force the user to wait*. Those with script solutions can just skip the trouble.
22nd Jan 2017, 5:02 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
* (the render wait + update can be one of the more maddening/infuriating things to users--they go to click/tap/even READ something and the document CHANGES position on them. Then it does it again. Don't be that dev.)
22nd Jan 2017, 5:19 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Write this code <a href="your webpage address">img src="location of your image"</a>
22nd Jan 2017, 7:14 PM
Shashank T
Shashank T - avatar
+ 1
u can use Image maping techniques which works as anchor tag!! and awesome to link web page in the image... if any help related to image mapping u can ask me
23rd Jan 2017, 4:49 AM
Bibek Magar
Bibek Magar - avatar
0
put the IMG tag inside an anchor tag
21st Jan 2017, 12:57 PM
Vaibhav Bhawalkar
Vaibhav Bhawalkar - avatar
0
* items already taken below. Using jQuery for... ====One image... <img id="myImage" .../> $("#myImage").click(function() { document.location.href="..."; }) ====A gallery... <img class="galleryPic" data-seq="1" .../> <img class="galleryPic" data-seq="2" .../> $(".galleryPic").click(function() { var seq=$(this).data("seq"); window.location.href="build_link-" + seq + ".html"; }); Obviously (for large pages) you would want to generate the sequences automatically (server or client side). *Taken: <a>nchor wrapping image... image with location.href redirect on tag... custom function + onclick..
21st Jan 2017, 1:29 PM
Kirk Schafer
Kirk Schafer - avatar
0
if you know how to use images and know how to create links, simply combine the two: create your link and replace the text part with the image source.
22nd Jan 2017, 5:38 AM
Andre van Rensburg
Andre van Rensburg - avatar
0
<a href="LINK"> <img src"image link"> </IMG> </a> that it
22nd Jan 2017, 3:53 PM
JideGuru
JideGuru - avatar
0
Put an image tag in between the anchor start and end tags
22nd Jan 2017, 7:01 PM
Atom Roese
Atom Roese - avatar
0
by using the <a href="www.example.com"><\a> method
22nd Jan 2017, 7:58 PM
Aman Singh Rathore
Aman Singh Rathore - avatar
0
I made a solution with a user input section so you can link to wherever you want depending on what you type in, defaults to Google.com but can be changed... so can the source image to click of course. Since I can't figure out how to link to the code I made just click on my profile and go to codes, it'll be the most recent.
23rd Jan 2017, 4:08 AM
sniperisdemoman
sniperisdemoman - avatar
- 4
You must write a function on javascript.Example:( <script type="text/javascript"> function abc(){ //action that you want } </script>) And add an atribute called "onclick". Example: (<button onclick="abc"></button>)
21st Jan 2017, 12:26 PM
Иван Литовский
Иван Литовский - avatar