Computer >> Computer tutorials >  >> Programming >> Javascript

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


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('https://qries.com');
         }
      </script>
      <p>Web page loads after 5 seconds.</p>
   </body>
</html>