Load images after the web page is loaded


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. <!--
  5. function getImage(pExistingImageID, pImageURL){
  6. var img = document.createElement('img');
  7. img.onload = function (evt) {
  8. document.getElementById(pExistingImageID).src=this.src;
  9. document.getElementById(pExistingImageID).width=this.width;
  10. document.getElementById(pExistingImageID).height=this.height;
  11. }
  12. img.src = pImageURL;
  13. return false;
  14. }
  15. //-->
  16. </script>
  17. <title>Remote Image 5</title>
  18. </head>
  19.  
  20. <body>
  21. <p><a href="#" onclick="return getImage('placeHolder','/images/rdivilbiss.jpg');">Get Remote Image</a></p>
  22. <p><img id="placeHolder" border="0" src="/images/placeHolder.jpg"></p>
  23. </body>
  24. </html>

URL: http://www.rodsdot.com/ee/scriptingRemoteImages.asp

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.