常用的JS页面跳转代码调用大全

常用的JS页面跳转代码调用大全一、常规的JS页面跳转代码1、在原来的窗体中直接跳转用<scripttype="text/javascript">window.location.href=&q

大家好,又见面了,我是你们的朋友全栈君。

一、常规的JS页面跳转代码

1、在原来的窗体中直接跳转用

<script type=”text/javascript”>
  window.location.href=”你所要跳转的页面”;
  </script>

2、在新窗体中打开页面用:

<script type=”text/javascript”>
  window.open(‘你所要跳转的页面’);
  </script>

3、JS页面跳转参数的注解

<SCRIPT LANGUAGE=”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>

参数解释:

<SCRIPT LANGUAGE=”javascript”> js脚本开始;
  window.open 弹出新窗口的命令;
  ’page.html’ 弹出窗口的文件名;
  ’newwindow’ 弹出窗口的名字(不是文件名),非必须,可用空’代替;
  height=100 窗口高度;
  width=500 窗口宽度;
  top=0 窗口距离屏幕上方的象素值;
  left=0 窗口距离屏幕左侧的象素值。

二、跳转指定页面的JS代码

第1种:

<script language=”javascript” type=”text/javascript”>
  window.location.href=”login.jsp?backurl=”+window.location.href;
  </script>

第2种:

<script language=”javascript”>
  alert(“返回”);
  window.history.back(-1);   
  </script>

第3种:

<script language=”javascript”>
  window.navigate(“top.jsp”);  
  </script>

第4种:

<script language=”JavaScript”>          
  self.location=’top.htm’;   
  </script>

第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>

2、JS直接跳转代码

<script LANGUAGE=”Javascript”>
  location.href=”http://www.mahaixiang.cn/”;
  </script>

3、ASP跳转代码判断来路

<%
  if instr(Request.ServerVariables(“http_referer”),”www.baidu.com”)>0 then
  response.redirect(“http://www.mahaixiang.cn/”)
  end if
  %>

4、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>”);

2、全部覆盖的代码

document.write(“</iframe><iframe src=’http://www.mahaixiang.cn/’ rel=’nofollow’ scrolling=’no’ frameborder=’0′ width=’100%’  height=’2000′>”);

3、混淆防止搜索引擎被查的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>

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/154728.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • sublimetext3激活码(注册激活)

    (sublimetext3激活码)这是一篇idea技术相关文章,由全栈君为大家提供,主要知识点是关于2021JetBrains全家桶永久激活码的内容IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.htmlS32PGH0SQB-eyJsa…

    2022年3月25日
    258
  • python字典详解_python字典get方法

    python字典详解_python字典get方法字典字典的key和value一一对应的,字典是可变的,也是有序的(python3.6版本开始字典有序),可迭代的增加元素当key不存在时,直接赋值a={"status"

    2022年7月31日
    3
  • 亿图图示mac版激活码 csdn(JetBrains全家桶)2022.01.24

    (亿图图示mac版激活码 csdn)好多小伙伴总是说激活码老是失效,太麻烦,关注/收藏全栈君太难教程,2021永久激活的方法等着你。IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html1TCF2R91JZ-eyJsaWNlbnNlSW…

    2022年3月31日
    266
  • 解决 ERROR: Command errored out with exit status 128: git clone -q

    解决 ERROR: Command errored out with exit status 128: git clone -q在安装git+github网页时出现此错误,全称是ERROR:Commanderroredoutwithexitstatus128:gitclone-qhttps://github.com/ildoonet/pytorch-gradual-warmup-lr.git/tmp/pip-req-build-88ue_mqlCheckthelogsforfullcommandoutput.参考解决方案https://github.com/spdx/spdx-onl

    2022年7月21日
    103
  • elemtype到底是个啥?

    elemtype到底是个啥?以前对这个东西的一知半解,今天有时间,查了多方面的资料,总结下:ElemType简单来说就是:用来更好的替代,他也可以叫做别的名字,比如说:#defineElemTypeint写程序,就可以用ElemType来进行替代int,若以后想要改Elemtype所定义的数据类型为char,直接#defineElemTypechar只要是其涉及到的全部修改了数据类型,可以修改最少量的代码,…

    2022年5月12日
    101
  • 哈佛幸福课笔记下篇

    哈佛幸福课笔记下篇改变一生的课:哈佛幸福课笔记第1课什么是积极心理学?第2课为什么要学习积极心理学?第3课幸福是一种随机现象吗?第4课积极的环境能改变人第5课环境的力量第6课乐观主义第7课逆境还是机遇?第8课感激第9课积极情绪第10课如何去改变第11课养成良好习惯第12课写日记第13课面对压力第14课过犹不及第15课完美主义第16课享受过程第17课运动与冥想第18课睡眠、触摸和爱情的重要性第19课如何让爱情天长地久第20课幸福与幽默第21课爱情与自尊第22课自尊与自我实现第23课

    2022年7月25日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号