1.使用meta元素
<meta http-equiv="refresh" content="5;url=hello.html">
http-equiv=“refresh” 是刷新页面,5秒后执行刷新操作,url是跳转的目的页面地址。
<meta http-equiv="refresh" content="5">
这行代码的意思是只刷新,不跳转。
2.使用script代码
立即跳转到hello.html页面。
<script type="text/javascript">
window.location.href = 'hello.html';
</script>
或者
<script language="javascript">
location.replace("http://www.baidu.com/");
</script>
5秒后跳转到hello.html页面。
<script type="text/javascript">
setTimeout("window.location.href = 'hello.html'", 5000);
</script>
3.判断是否手机端
<script type="text/javascript">
var wapurl = window.location.pathname;
if
(/Android|webOS|iPhone|iPod|BlackBerry|Windows CE|Windows Phone/i.test(navigator.userAgent))
{if
(window.location.href.toLowerCase().indexOf("?pc")<0)
{try
{window.location.href="/wap"+wapurl}
catch(e){}}
}
</script>
本文介绍了三种实现网页刷新和跳转的方法:通过HTML的meta标签和JavaScript代码。详细解析了如何设置延迟时间以及如何针对移动端进行特定的跳转处理。
835

被折叠的 条评论
为什么被折叠?



