Delay automatic url redirect with jquery?

让人想犯罪 __ 提交于 2019-11-30 02:48:59

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

setTimeout(function() {
  window.location.href = "/NewPage.aspx";
}, 2000);
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";
});

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!