欢迎您光临自学哈网,只为分享网络知识教程,供大家学习参考!

「自学哈网」html、js常用的跳转代码

作者 : 自学哈 本文共1147个字,预计阅读时间需要3分钟 2023-08-4 共79人阅读
也想出现在这里? 联系我们

html、js常用的跳转代码

网站部分页面需要经常使用跳转码,比如自动跳转到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.nzw6.com" rel="external nofollow" 
 }
 //\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>

 

 

本站声明:
本站所有资源来源于网络,分享目的仅供大家学习和交流!如若本站内容侵犯了原著者的合法权益,可联系邮箱976157886@qq.com进行删除。
自学哈专注于免费提供最新的分享知识、网络教程、网络技术的资源分享平台,好资源不私藏,大家一起分享!

自学哈网 » 「自学哈网」html、js常用的跳转代码
也想出现在这里? 联系我们
© 2022 Theme by - 自学哈网 & WordPress Theme. All rights reserved 浙ICP备2022016594号