Question

I can't seem to get the setTimeOut() function working. Below is the javascript that I have been working on:

    function hideImage()
    {
        document.getElementById('loadingimg').style.visibility='hidden';        
    }
    function showImage()
    {
        document.getElementById('loadingimg').style.visibility='visible';
        setTimeOut(hideImage, 3000);
    }

Whenever I call the function showImage(), the gif image is displayed in the page. However, the image does not hide after 3 seconds, even though I called the setTimeOut() method.

Was it helpful?

Solution 3

Yani and others are right. Its case sensitivity error. Just FYI, here is my piece of working code for you:

<html>
<head>
</head>
<body onload="Init()">
<img id="loadingimg" height="24" width="24" src="ball.gif">
<script type="text/javascript">

function hideImage()
    {
        document.getElementById('loadingimg').style.visibility='hidden';        
        //document.getElementById('loadingimg').style.display = "none";
    }
    function showImage()
    {
        document.getElementById('loadingimg').style.visibility='visible';
        setTimeout(hideImage, 3000);
    }
function Init()
{
    showImage();
}
</script>
</body>
</html>


Regards,
dennis

OTHER TIPS

Change setTimeOut to setTimeout. It's case sensitive.

Case mistake.

Try setTimeout rather than setTimeOut.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top