How to use JavaScript to load a webpage after 5 seconds?

JavascriptWeb DevelopmentFront End Technology

Use the setTimeout() function in JavaScript to load a webpage after some interval. This function waits for some seconds and then loads the web page.

Example

You can try to run the following code to learn how to load a webpage after 5 seconds −

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <script>
         setTimeout(myURL, 5000);
         function myURL(){
            window.open('http://qries.com');
         }
      </script>
      <p>Web page loads after 5 seconds.</p>
   </body>
</html>
raja
Published on 01-Feb-2018 05:18:31
Advertisements