html、js常用的跳转代码

2022-12-05 0 318

htmljs常用的跳转代码

网站部分页面需要经常使用跳转码,比如自动跳转到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>

 

 

1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!cheeksyu@vip.qq.com
2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理!
3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有积分奖励和额外收入!
5.严禁将资源用于任何违法犯罪行为,不得违反国家法律,否则责任自负,一切法律责任与本站无关

源码下载

发表评论
暂无评论