进入a.html2秒后,自动跳转到同目录下的b.html文件<head>
方法1:
- <head>
- <meta http-equiv="refresh" content="2;url='b.html'">
- </head>
<head>
<meta http-equiv="refresh" content="2;url='b.html'">
</head>
方法2:
- <script language="javascript" type="text/javascript">
- setTimeout("window.location.href='b.html'", 2000);
- //下面两个都可以用
- //setTimeout("javascript:location.href='b.html'", 2000);
- //setTimeout("window.location='b.html'", 2000);
- </script>
<script language="javascript" type="text/javascript">
setTimeout("window.location.href='b.html'", 2000);
//下面两个都可以用
//setTimeout("javascript:location.href='b.html'", 2000);
//setTimeout("window.location='b.html'", 2000);
</script>
方法2扩展:
- <span id="totalSecond">2</span>
- <script language="javascript" type="text/javascript">
- var second = document.getElementById('totalSecond').innerHTML;
- if(isNaN(second)){
- //……不是数字的处理方法
- }else{
- setInterval(function(){
- document.getElementById('totalSecond').innerHTML = --second;
- if (second <= 0) {
- window.location = 'b.html';
- }
- }, 1000);
- }
- </script>