Posted By

eden159 on 01/05/09


Tagged

javascript image html load programming


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wirenaught


Load images after the web page is loaded


 / Published in: JavaScript
 

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

  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>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: rdivilbiss on October 12, 2010

I am the author.

The link to the page has moved to http://www.rodsdot.com/javascript/Remote-Scripting-Images-%28No-Need-For-AJAX%29.asp.

While the central storage location for scripts and code has many merits, the use of my code does require attribution per the Terms Of Used posted at my site.

Users of this site are strongly encouraged to visit the original code to obtain the latest version with any bug fixes, security enhancements, or improvements.

You need to login to post a comment.