caching - Refresh Image onload with Javascript? -
i'm working on wordpress editor need able refresh images without having reload page. however, i'm not getting plot i'm not javascript master :(
i'm running this, in console log, is: "uncaught referenceerror: updateimage not defined". doing wrong?
<script> var newimage = new image(); newimage.src = "http://2famous.tv/wp-content/uploads/2013/07/dubai-sky-scrapers_thumb_one.jpg"; function updateimage() { if(newimage.complete) { document.getelementbyid("thumb1").src = newimage.src; newimage = new image(); newimage.src = "http://2famous.tv/wp-content/uploads/2013/07/dubai-sky-scrapers_thumb_one.jpg?" + new date().gettime(); } settimeout(updateimage, 1000); }; </script> <img id="thumb1" src="image.jpg" onload="updateimage();">
when <img> loading, <script> not loaded yet. so, updateimage() method doesn't exists. try use jquery, there ready event.
Comments
Post a Comment