I am trying a JavaScript function after 10 second of body load. But it is showing immediatly after body load. I am not expert in JavaScript, so I am not able to find where is the problem. my code is below:
<script type="text/javascript">
window.onload=setInterval(div_show(), 10);
</script>
                <script>
    window.onload = function(){
        //time is set in milliseconds
        setTimeout(div_show, 10000)
    };
</script>
                        You need to:
onload. setInterval returns an interval id, not a functionsetInterval, div_show() will call the div_show function and pass its return valuesetInterval's second argument is accepts a number of milliseconds not seconds.Such:
onload = function () {
    setInterval(div_show, 10 * 1000);
}
Finally, if you want to run the function 10 seconds after the document loads, rather than every 10 seconds starting from when the document loads, use setTimeout instead of setInterval.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With