How to use Window Object SetTimeout in JavaScript

In this article I am going to explain about window object SetTimeout() Method in JavaScript.
  • 1137

JavaScript Window object SetTimeout() Method

JavaScript SetTimeout() method use for call a function after specified number of time.

Syntax

Window.SetTimeout(Function(), Milisecond)

Example // In this example when you will click on the button then a message will be display after 5 second

<html>

<head>

    <script type="text/javascript">

        function TimeFun() {

            var t = setTimeout("myfun()", 5000)

        }

        function myfun() {

            alert("Hello friends");

        }

    </script>

</head>

<body>

    <form>

    <p>

        When you will click on the button then a meessage<br />

        will be display after five second</p>

    <input type="button" value="click me" onclick="TimeFun()" />

    </form>

</body>

</html>

 

Output


settime.gif

 

You may also want to read these related articles: here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.