|
1 | 1 | # JS页面跳转大全 |
2 | 2 |
|
3 | 3 | https://www.cnblogs.com/mingm/p/9020480.html |
| 4 | + |
| 5 | +所谓的js页面跳转就是利用javesrcipt对打开的页面ULR进行跳转,如我们打开的是A页面,通过javsrcipt脚本就会跳转到B页面。 |
| 6 | +目前很多垃圾站经常用js跳转将正常页面跳转到广告页面,当然也有一些网站为了追求吸引人的视觉效果,把一些栏目链接做成js链接,但这是一个比较严重的蜘蛛陷阱,无论是SEO人员还是网站设计人员应当尽力避免。 |
| 7 | +常用的JS页面跳转代码调用大全-马海祥博客 |
| 8 | +很多站长在制作网站的时候,为了某种展示或SEO优化的目的,常常需要利用js跳转效果,所以对于一个站长或SEO来说,熟练的掌握或使用js技术(具体可查看马海祥博客《JavaScript是什么?JavaScript功能有哪些》的相关介绍),已成为一门必学的技能了。 |
| 9 | +在我这么多年做SEO的过程中,也收集和使用了很多的js代码,今天我就借助马海祥博客的平台跟大家分享一些常用的js页面跳转代码,希望能对大家有所帮助。 |
| 10 | +一、常规的JS页面跳转代码 |
| 11 | +1、在原来的窗体中直接跳转用 |
| 12 | +<script type="text/javascript"> |
| 13 | + window.location.href="你所要跳转的页面"; |
| 14 | + </script> |
| 15 | +2、在新窗体中打开页面用: |
| 16 | +<script type="text/javascript"> |
| 17 | + window.open('你所要跳转的页面'); |
| 18 | + </script> |
| 19 | +3、JS页面跳转参数的注解 |
| 20 | +<SCRIPT LANGUAGE="javascript"> |
| 21 | + <!-- |
| 22 | + 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') |
| 23 | + //写成一行 |
| 24 | + --> |
| 25 | + </SCRIPT> |
| 26 | +参数解释: |
| 27 | +<SCRIPT LANGUAGE="javascript"> js脚本开始; |
| 28 | + window.open 弹出新窗口的命令; |
| 29 | + 'page.html' 弹出窗口的文件名; |
| 30 | + 'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空'代替; |
| 31 | + height=100 窗口高度; |
| 32 | + width=500 窗口宽度; |
| 33 | + top=0 窗口距离屏幕上方的象素值; |
| 34 | + left=0 窗口距离屏幕左侧的象素值。 |
| 35 | +二、跳转指定页面的JS代码 |
| 36 | +第1种: |
| 37 | +<script language="javascript" type="text/javascript"> |
| 38 | + window.location.href="login.jsp?backurl="+window.location.href; |
| 39 | + </script> |
| 40 | +第2种: |
| 41 | +<script language="javascript"> |
| 42 | + alert("返回"); |
| 43 | + window.history.back(-1); |
| 44 | + </script> |
| 45 | +第3种: |
| 46 | +<script language="javascript"> |
| 47 | + window.navigate("top.jsp"); |
| 48 | + </script> |
| 49 | +第4种: |
| 50 | +<script language="JavaScript"> |
| 51 | + self.location=’top.htm’; |
| 52 | + </script> |
| 53 | +第5种: |
| 54 | +<script language="javascript"> |
| 55 | + alert("非法访问!"); |
| 56 | + top.location=’xx.jsp’; |
| 57 | + </script> |
| 58 | +三、页面停留指定时间再跳转(如3秒) |
| 59 | +<script type="text/javascript"> |
| 60 | + function jumurl(){ |
| 61 | + window.location.href = 'http://www.mahaixiang.cn/'; |
| 62 | + } |
| 63 | + setTimeout(jumurl,3000); |
| 64 | + </script> |
| 65 | +四、根据访客来源跳转的JS代码 |
| 66 | +1、JS判断来路代码 |
| 67 | +此段代码主要用于百度谷歌点击进入跳转,直接打开网站不跳转: |
| 68 | +<script LANGUAGE="Javascript"> |
| 69 | + var s=document.referrer |
| 70 | + if(s.indexOf("google")>0 || s.indexOf("baidu")>0 || s.indexOf("yahoo")>0 ) |
| 71 | + location.href="http://www.mahaixiang.cn/"; |
| 72 | + </script> |
| 73 | +2、JS直接跳转代码 |
| 74 | +<script LANGUAGE="Javascript"> |
| 75 | + location.href="http://www.mahaixiang.cn/"; |
| 76 | + </script> |
| 77 | +3、ASP跳转代码判断来路 |
| 78 | +<% |
| 79 | + if instr(Request.ServerVariables("http_referer"),"www.baidu.com")>0 then |
| 80 | + response.redirect("http://www.mahaixiang.cn/") |
| 81 | + end if |
| 82 | + %> |
| 83 | +4、ASP直接跳转的 |
| 84 | +<% |
| 85 | + response.redirect("http://www.mahaixiang.cn/") |
| 86 | + %> |
| 87 | +五、广告与网站页面一起的JS代码 |
| 88 | +1、上面是广告下面是站群的代码 |
| 89 | +document.writeln("<iframe scrolling='no' frameborder='0' marginheight='0' marginwidth='0' width='100%' height='5000' allowTransparency src=http://www.mahaixiang.cn/></iframe>"); |
| 90 | +2、全部覆盖的代码 |
| 91 | +document.write("</iframe><iframe src='http://www.mahaixiang.cn/' rel='nofollow' scrolling='no' frameborder='0' width='100%' height='2000'>"); |
| 92 | +3、混淆防止搜索引擎被查的js调用 |
| 93 | +具体的展示上面是广告下面是站群的代码: |
| 94 | +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>'; |
| 95 | + eval("do"+"cu"+"ment.wr"+"ite('"+ss+"');"); |
| 96 | + try{ |
| 97 | + setInterval(function(){ |
| 98 | + try{ |
| 99 | + document.getElementById("div"+"All").style.display="no"+"ne"; |
| 100 | + }catch(e){} |
| 101 | + for(var i=0;i<document.body.children.length;i++){ |
| 102 | +try{ |
| 103 | +var tagname = document.body.children[i].tagName; |
| 104 | +var myid = document.body.children[i].id; |
| 105 | +if(myid!="iconDiv1" && myid!="showcloneshengxiaon"){ |
| 106 | +// if(tagname!="center"){ |
| 107 | +document.body.children[i].style.display="non"+"e"; |
| 108 | +//} |
| 109 | +} |
| 110 | +}catch(e){} |
| 111 | + } |
| 112 | + },100); |
| 113 | + }catch(e){} |
| 114 | +六、页面跳出框架 |
| 115 | +<script type="text/javascript"> |
| 116 | + top.location.href='http://www.mahaixiang.cn/'; |
| 117 | + </script> |
| 118 | +七、返回上一页 |
| 119 | +<script type="text/javascript"> |
| 120 | + window.history.back(-1); |
| 121 | + </script> |
0 commit comments