Getting image src when is loaded using setTimout
-
hi everyone. So let's say I have the following html code:
@<html>
<head></head>
function changePic(){
document.getElementById("somePic").src="http://qt.nokia.com/images/template/icon-qt-in-a-box";
}
<body onload="setTimeout('changePic();',1000);">some text<br></br> <img id="somePic" title="about the pic" src=""></img> </body>
</html>@
I'm interested in getting the image source (src attribute). When the loadFinished is emited the src attribute is "" because the image will be loaded only after 1 second after the page is loaded.
Is there a way to solve this?
-
add an listener on image.so
@
<html>
<head></head>
function changePic(){
document.getElementById("somePic").src="http://qt.nokia.com/images/template/icon-qt-in-a-box";
}
function showSrc(img){
alert(img.src);
}
<body>some text<br></br> <img id="somePic" title="about the pic" src="" onload="showSrc(this)"></img> </body>
</html>
@