html页面自动跳转的两种办法
下面举例说明,在2秒后,自动跳到百度首页的几种方法。1.html的实现< head>< !-- 以下方式只是刷新不跳转到其他页面 -->< me ta http-equiv="refresh" content="2">< !-- 以下方式定时转到其他页面 --&
·
下面举例说明,在2秒后,自动跳到百度首页的几种方法。
1.html的实现
< head>
< !-- 以下方式只是刷新不跳转到其他页面 -->
< me ta http-equiv="refresh" content="2">
< !-- 以下方式定时转到其他页面 -->
< me ta http-equiv="refresh" content="2;url=http://www.baidu.com">
< /head>
这种方法比较简单!
2.javascript的实现
< script language="javascript" type="text/javascript">
//以下方式直接跳转
window.location.href='http://www.baidu.com';
//以下方式定时跳转
setTimeout("javascript:location.href='http://www.baidu.com'", 2000);
< /script>
这种方法比较灵活,可以结合更多的其他功能使用;但是会受到不同浏览器的影响。
html代码因受格式限制,在代码间加入空格。注意!!
更多推荐
已为社区贡献1条内容
所有评论(0)