在导航按钮上设置1秒超时

时间:2013-09-23 07:57:04

标签: javascript delay settimeout

我的(cms)网站上有一个滑块导航,该导航中的链接需要在1秒后加载URL。

导航现在看起来像这样:

<div class="slides">
  <div class="slideItem"><a href="page1.html">link1</a></div>
  <div class="slideItem"><a href="page2.html">link2</a></div>
  <div class="slideItem"><a href="page3.html">link3</a></div>
</div>

我发现下面的脚本可以用于href吗? (如果这样的话)。

setTimeout( "window.location.href = 'http://domain.com/url.html'", 5*1000 );

1 个答案:

答案 0 :(得分:0)

这将在5秒后将用户重定向到http://domain.com/url.html

setTimeout( "window.location.href = 'http://domain.com/url.html'", 5*1000 );

如果你想要1秒延迟使用1000作为第二个参数, 你有没有看过这个剧本? 你想要实现什么?