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>
        
        &lt;img id="somePic" title="about the pic" src=""&gt;&lt;/img&gt;        
    &lt;/body&gt;
    

    </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>
         
       &lt;img id="somePic" title="about the pic" src="" onload="showSrc(this&#41;"&gt;&lt;/img&gt;        
    &lt;/body&gt;
    

    </html>

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.