网站常用跳转html、js代码教程

廖为祥 网站源码评论3,638阅读模式

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

网站常用跳转html、js代码教程

 1、html网页跳转代码
在网页头部<1head>…</head>之间插入以下代码

  &lt;meta http-equiv="refresh" content="0.1;url=****(要跳转的网址)"&gt;

其中: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.softwen.cn"
 }
 //\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 !='https://www.liaoweixiang.com' && document.domain !='https://liaoweixiang.com'){
window.location.href='http://liaoweixiang';
}
//记得把上面网址更改为自己网站地址
</script>
</body>
</html>

继续阅读
廖为祥
  • 本文由 发表于 2020年5月18日 11:19:35
  • 除特别声明外,本站原创内容版权遵循 CC BY-NC-ND/2.5/CN协议规定
评论  0  访客  0

发表评论