HTML实现页面自动跳的方法
HTML实现页面自动跳的方法
1.1方法一
直接在<head></head>标签内添加<meta>标签。代码如下:
<head>
<meta http-equiv="refresh" content="3;URL=res.html">
<!--3秒之后自动跳转到res.html页面-->
</head>1.2方法二
使用JSsetTimeout函数定义经过指定毫秒值后执行某一表达式。代码如下:
<script>
setTimeout(function (){
location.href=" res.html ";
},3000); //3秒之后自动执行函数,直接跳转到res.html页面
</script>1.3方法三
上面两个例子的缺陷就是能够实现跳转,但是不知道是什么时候跳转。实现倒数3-2-1,JSsettimeout函数无法做到,需使用JSsetInterval函数定义每经过指定毫秒值后执行某一个表达式。代码如下:
<script>
var x=3;//利用了全局变量来执行
setInterval(function (){
x--;
x>0? document.getElementById("info").innerHTML=x : location.href='123.html';
},1000);
</script> 相关推荐
lupeng 2020-11-14
sjcheck 2020-11-10
meylovezn 2020-08-28
owhile 2020-08-18
Francismingren 2020-08-17
pythonclass 2020-07-29
sunzhihaofuture 2020-07-19
爱读书的旅行者 2020-07-07
行吟阁 2020-07-05
tianqi 2020-07-05
行吟阁 2020-07-04
冰蝶 2020-07-04
lyg0 2020-07-04
owhile 2020-07-04
opspider 2020-06-28
lengyu0 2020-06-28
tianqi 2020-06-21
dadaooxx 2020-06-16