js 跳转页面想必大家不会很陌生吧,在浏览页面的时候经常会碰到这种现象存在如果可以延迟的话是不是会更委婉一点呢,接下来为大家介绍下如何实现,感兴趣的朋友可以参考下哈
Javascript 是一种由 Netscape 的 LiveScript 发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如 Perl,遗留的速度问题,为客户提供更流畅的浏览效果。
方法 1:
- <SPAN style="FONT-SIZE: 12px">
- <script type="text/javascript">
- < !--
- function go(t, url) {
- //t设置跳转时间:秒
- //url设置跳转网址
- document.write("<div id=text>本页将在<strong id='tt'></strong>后,跳转至:<span id='link'></span></div>");
- document.getElementById("link").innerhtml = "<a href=" + url + ">" + url + "</a>";
- $(t, url);
- }
- function $(t, url) {
- ta = t - 1;
- tb = t + "000";
- d = document.getElementById("tt");
- d.innerHTML = t;
- window.setInterval(function() {
- go_to(url);
- },
- 1000);
- }
- function go_to(url) {
- d.innerHTML = ta--;
- if (ta < 0) {
- document.write("正在跳转至:<a href=" + url + ">" + url + "</a>");
- location.href = url;
- } else {
- return;
- }
- }
- //-->
- </script>
- <script type="text/javascript">
- go(5, "/Login.aspx")
- </script>
- </SPAN>
方法 2:
- window.setTimeout("window.location='index.shtml'",2000);
- //两秒后跳转新页面
来源: