HTML img onclick Javascript

user3579754 picture user3579754 · Apr 28, 2014 · Viewed 254.3k times · Source

How do I have JavaScript open the current image in a new WINDOW with an ONCLICK event.

<script>
 function imgWindow() {
  window.open("image") }
</script>

HTML

<img src="pond1.jpg" height="150" size="150" alt="Johnson Pond" onclick="image()"> <-- Have JavaScript open this image with onclick.
<img src="pond2.jpg" height="150" size="150" alt="All-green Pond" onclick="image()"> <-- Have JavaScript open this image with onclick.
<img src="pond3.jpg" height="150" size="150" alt="Dutch Pond" onclick="image()"> <-- Have JavaScript open this image with onclick.

Answer

Ben picture Ben · Apr 28, 2014

here you go.

<img src="https://i.imgur.com/7KpCS0Y.jpg" onclick="window.open(this.src)">