网站常用跳转html、js代码大全
网站有些页面需要经常用到跳转代码比如404页面自动跳转

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.laoyublog.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.laoyublog.com' && document.domain !='https://laoyublog.com'){
window.location.href='http://laoyublog';
}
//记得把上面网址更改为自己网站地址
</script>
</body>
</html>信息由用户投稿以及用户自行发布,真实性、合法性由发布人负责,涉及到汇款等个人财产或隐私内容时请仔细甄别,注意防骗!如有侵权,请联系:wwwlaoyuwang#126.com(#=@)!我们会第一时间核实处理!
上一篇