Page Redirect after X seconds wait using JavaScript

0 votes

After displaying an error notice, I need to redirect to a specified URL after 5 seconds. 

First, I utilized Javascript as seen below.

document.ready(window.setTimeout(location.href = "https://www.google.co.in",5000));

However, it is not waiting 5 seconds. Then I googled the problem and discovered that "document.ready()" is called when a document is loaded at the DOM rather than the web browser.

Then I used jQuery's window.load() function, but I still don't get what I want.

$(window).load(function() {
               window.setTimeout(window.location.href = "https://www.google.co.in",5000);
            });

Could someone kindly tell me what I need to do to wait 5 seconds?

Sep 28 in Java by Nicholas
• 7,420 points
163 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java

0 votes
1 answer

Refresh a page using JavaScript or HTML

This can be solved by using the ...READ MORE

answered Feb 18 in Java by Aditya
• 7,660 points
90 views
0 votes
1 answer

Refresh a page using JavaScript or HTML

window.location.reload(); in JavaScript <meta http-equiv="refresh" content="1"> in HTML ...READ MORE

answered Nov 7 in Java by Damonlang
• 700 points
38 views
0 votes
2 answers
0 votes
1 answer

Convert Milliseconds to “X mins, x seconds” in Java?

I wrote a function which converts milliseconds ...READ MORE

answered May 30, 2018 in Java by Rishabh
• 3,620 points
2,486 views
0 votes
2 answers

Scanner is skipping nextLine() after using next() or nextFoo()?

use input.nextLine(); after your nextInt() function for example:- input.nextInt(); ...READ MORE

answered May 11, 2019 in Java by Sourav Dangi
14,331 views
0 votes
1 answer

How to call a method after a delay in Android using Java?

final Handler handler = new Handler(); handler.postDelayed(new Runnable() ...READ MORE

answered Jun 11, 2018 in Java by Akrati
• 3,190 points
4,677 views
0 votes
1 answer

Using setTimeout to delay timing of jQuery actions

The JavaScript setTimeout () function  is used ...READ MORE

answered May 30 in Java by gaurav
• 22,040 points
290 views
0 votes
1 answer

Best cross-browser method to capture CTRL+S with JQuery?

$(window).keypress(function(event) { if ...READ MORE

answered May 30 in JQuery by gaurav
• 22,040 points
348 views
0 votes
1 answer

jQuery.inArray(), how to use it right?

The jQuery inArray() method is used to find ...READ MORE

answered Jun 1 in JQuery by Edureka
• 13,640 points
68 views
0 votes
1 answer

Which keycode for escape key with jQuery

27 is the code for the escape key. ...READ MORE

answered Jun 1 in JQuery by Edureka
• 13,640 points
405 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP