Step 3 − In the last step, we will define the call back function of the setTimeout() method which uses the object to redirect the page after given interval of time. Step 2 − In this step, we will call the setTimeout() method with a callback function and a time interval inside the function declared in previous step. Step 1 − In the first step, we will define a call-back function for the onclick event associated with the button tag in the HTML document. Let us understand the code implementation of the setTimeout() method to redirect the page after 5 seconds. The following syntax will be used to implement the setTimeout() method with the object − setTimeout(callBack_func, timeInterval) We will use the setTimeout() method as usual by giving it a call-back function and by specifying a particular limit of time after which it will invoke the call-back function which will redirect the web page. Let us understand the use of the setTimeout() and the setInterval() methods with object one by one in detail to delay web page redirection by 5 seconds. To redirect a page we will use the or object of JavaScript as shown below − ="" Lts look at the use of these methods to redirect a web page by 5 seconds. Add the webpage in object.Īs we know, whenever we need to call a function or some block of code after a specific delay of time we use the setTimeout() and the setInterval() methods of JavaScript. To redirect a webpage after 5 seconds, use the setInterval() method to set the time interval. In this tutorial, we learn to use JavaScript to redirect a webpage after 5 seconds.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |