html、js常用的跳转代码
网站部分页面需要经常使用跳转码,比如自动跳转到404页面
![图片[1]-html、js常用的跳转代码-2345资源网 - 精品建站资源与技术分享平台](https://i1.nzw6.com/imgs/2022/12/3948239819714541989.jpg)
1、html网页跳转代码
在网页头部<1head>…</head>之间插入以下代码 <meta http-equiv="refresh" content="0.1;url=****(要跳转的网址)">
其中:content=”0.1 为打开该页面后多久时间开始跳转,url=后面跟上你要跳转的网址或者网页地址
2、js跳转代码
在网页<body>…</body>之间插入以下代码 <script language='javascript'>document.location = '****(要跳转的网址)'</script>
3、asp网页跳转代码
<%
Response.Redirect("****(要跳转的网址)")
Response.End
%>
4、php网页跳转代码
<?php
header("location: ****(要跳转的网址)");
?>
5、js访问根据地区/编码跳转代码(代码示例如下)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>js跳转代码示例</title>
</head>
<script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js" charset="GB2312"
></script>
<script type=text/javascript>
if(remote_ip_info.province =='\u5317\u4eac'){
}else {
window.location.href="http://www.nzw6.com"
}
//\u5317\u4eac代表地区Unicode编码转换
</script>
<body>
</body>
</html>
6、判断网站地址跳转,访问的不是这个地址跳转到指定地址(代码示例如下)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript">
if (document.domain !='http://www.nzw6.com' && document.domain !='https://laoyublog.com'){
window.location.href='http://www.nzw6.com';
}
//记得把上面网址更改为自己网站地址
</script>
</body>
</html>
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END












暂无评论内容