Prevent page load of images - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image

Description

Prevent page load of images

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <img id="myImg" src="" width="107" height="98"> 
      <button onclick="myFunction()">Load image</button> 
      <script>
function myFunction() {//from w  ww  . j a  va2 s . co m
    document.getElementById("myImg").src = "http://www.java2s.com/style/download.png";
}

      </script>  
   </body>
</html>

Related Tutorials