Delay automatic url redirect with jquery?

mark picture mark · Sep 9, 2010 · Viewed 57.9k times · Source

I need a transition page that will display for 2 seconds before automatically redirecting to the home page. How do I do this? I can't seem to get delay to work for me.

Answer

Nick Craver picture Nick Craver · Sep 9, 2010

You can just use setTimeout() directly, like this:

setTimeout(function() {
  window.location.href = "/NewPage.aspx";
}, 2000);