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.
setTimeout(function(){ window.location = "/NewPage.aspx"; }, 2000);
You could use jQuery Timer. Here is the code (also found in this article):
// This will hold our timer
var myTimer = {};
// delay 2 seconds
myTimer = $.timer(2000, function() {
//redirect to home page
window.location = "/RedirectTimer/Home.aspx";
});
You can just use setTimeout() directly, like this:
setTimeout(function() {
window.location.href = "/NewPage.aspx";
}, 2000);
Would the delay() function not work for you? Vanilla JavaScript with setTimeout()
would work equally well.
Hint: Suggesting actual code is kind of hard when you do not show your current code.