打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
html页面自动跳转方法
userphoto

2023.02.05 河北

关注

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>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
页面自动跳转
纯js页面跳转整理
PHP页面跳转
四个页面转向代码
HTML教程——必须知道的技巧30例
WEB消息提醒实现之二 实现方式-基于Iframe的流方式
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服