手机浏览网页自动跳转移动版js
实现网页页面跳转的几种方法(meta标签、js实现、php实现)

实现网页页面跳转的几种方法(meta标签、js实现、php实
现)
今天总结了几种页面跳转的方法,分别是用meta标签实现、用javascript实现、用php实现,下面就来一一分享一下吧。
1、meta标签实现
只需在head里加上下面这一句就行了,在当前页面停留0.1秒后跳转到目标页面
复制代码代码如下:
<meta http-equiv="refresh" content="0.1; url=/">
2、Javascript实现
方法一:
这个方法比较常用
复制代码代码如下:
window.location.href = "/";
方法二:
复制代码代码如下:
self.location = "/";
方法三:
复制代码代码如下:
top.location = "/";
方法四:
只对IE系列浏览器有效,实用性不大
复制代码代码如下:
window.navigate("/");
3、php实现
复制代码代码如下:
<?php
header("Location: /");
>
Ok,以上就是今天总结的几种页面跳转的方法了。
JS实现页面跳转与刷新的方法汇总

JS实现页⾯跳转与刷新的⽅法汇总window.location(.href)="URL"其实 .href 可以省略window.location 和window.location.href 实现的效果是⼀样的例如:window.location = ""window.location.href = 上⾯两种⽅法都可以从当前页⾯跳转到⽬标页⾯不同之处在于window.location 返回的是对象,如果没有.href,它会默认参数就是hrefwinodw.location.assign("URL")这个⽅法和上⾯的⽅法差不多⽤法:winodw.location.assign()window.location.replace("URL")如果⽤window.location.replace("") 实现跳转页⾯, 它和上⾯⽅法的区别在于它跳转后不会保存跳出页⾯的信息.所以如果使⽤ history 历史返回按钮是⽆效的它的效果类似于在⽹页上点击右键, 在新窗⼝打开或新标签页打开.⽽window.location.href 实现的效果是在页⾯上点击⽬标链接, 然后可以点击历史返回按钮, 返回到之前页⾯。
历史页跳转下⾯的两种⽅法都可以实现返回历史页,相当于点了页⾯左上⾓的返回按钮window.history.back();window.history.go(-1);back和go⾥⾯都可以放数值例如:⾥⾯放上 -1 意思就是返回上⼀级,⾥⾯放上 -2 就是返回上上级,以此类推⽽且⾥⾯还可以放上指定的路由路径,⽐如window.history.go('../routes/admin/'); 这样可以跳转到指定的路由模块meta refresh如果⽤户浏览器禁⽤了javascript, 那么可以⽤meta refresh来实现⾃动跳转:<noscript><meta http-equiv="refresh" content="0;URL=/"></noscript>如果要实现 JS ⾃动跳转,可以加个定时器:setTimeout(function(){ ... }, 1000);重新加载本页如果你的代码逻辑执⾏完了,想要重新加载页⾯的话,可以⽤这两种⽅法:window.location.reload()window.location.replace()这两种⽅法都可以重新加载本页,但是replace()可以导向另外⼀个URL例如:window.location.replace("")window.navigate('URL')window.navigate('URL')这个⽅法是只针对IE的,不适⽤于⽕狐等其他浏览器,在HTML DOM Window Object中,根本没有列出window.navigate这个⽅法,所以这个⽅法尽量少⽤,遗忘最好。
常用的JS页面跳转代码调用大全

常⽤的JS页⾯跳转代码调⽤⼤全⼀、常规的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 = '/'; } 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="/"; </script>2、JS直接跳转代码<script LANGUAGE="Javascript"> location.href="/"; </script>3、ASP跳转代码判断来路<% if instr(Request.ServerVariables("http_referer"),"")>0 then response.redirect("/") end if %>4、ASP直接跳转的<% response.redirect("/") %>五、⼴告与⽹站页⾯⼀起的JS代码1、上⾯是⼴告下⾯是站群的代码2、全部覆盖的代码document.write("</iframe><iframe src='/' 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='/'; </script>七、返回上⼀页<script type="text/javascript"> window.history.back(-1); </script>。
js方式的页面跳转

通过js或者html或者php等动态程序都可以方便的实现跳转,这里搜集了几种页面跳转的方式js方式的页面跳转1.window.location.href方式<script language="javascript" type="text/javascript">window.location.href="/";</script>2.window.navigate方式跳转<script language="javascript">window.navigate("top.jsp");</script>3.window.loction.replace方式实现页面跳转,注意跟第一种方式的区别<script language="javascript">window.location.replace("") ;</script>有3个jsp页面(1.jsp, 2.jsp, 3.jsp),进系统默认的是1.jsp ,当我进入2.jsp的时候,2.jsp 里面用window.location.replace("3.jsp");与用window.location.href ("3.jsp");从用户界面来看是没有什么区别的,但是当 3.jsp页面有一个"返回"按钮,调用window.history.go(-1); wondow.history.back();方法的时候,一点这个返回按钮就要返回2.jsp页面的话,区别就出来了,当用window.location.replace("3.jsp");连到 3.jsp页面的话,3.jsp页面中的调用window.history.go(-1);wondow.history.back();方法是不好用的,会返回到1.jsp 。
js跳转的几种方式

js跳转的几种方式
随着网站的开发和用户需求的不断变化,JavaScript跳转成为了页面跳转的常用方式之一。
下面介绍一些常用的JavaScript跳转方式:
1. window.location.href:该方式通过修改当前窗口的url地址实现跳转。
使用该方式时,页面会重新加载,同时浏览器的历史记录也会被修改,用户可以通过浏览器的后退按钮回到之前的页面。
2. window.location.replace:该方式也是通过修改url地址实现跳转。
使用该方式时,页面会重新加载,但是浏览器的历史记录会被删除,用户无法通过浏览器的后退按钮回到之前的页面。
3. window.location.assign:该方式也是通过修改url地址实现跳转。
使用该方式时,页面会重新加载,同时浏览器的历史记录也会被修改,用户可以通过浏览器的后退按钮回到之前的页面。
4. location.reload:该方式用于重新加载当前页面。
使用该方式时,浏览器会重新发送请求,获取最新的页面内容。
5. location.replace(location.href):该方式用于重新加载当前页面,并清除浏览器的历史记录。
使用该方式时,浏览器会重新发送请求,获取最新的页面内容,并删除浏览器的历史记录。
以上是JavaScript跳转的几种常用方式,开发者可以根据需求选择合适的方式来实现页面跳转。
- 1 -。
手机访问自动跳转触屏版 从触屏版访问电脑版不跳转

建站的时候建有PC版(电脑版)和触屏版(手机版),想要达到的功能是当第一次访问主页网址的时候自动判断,如果是电脑则访问PC版,如果是手机、Pad则跳转触屏版,而在手机版上点击访问电脑版时则直接访问电脑版(此时不再跳转成触屏版)。
可以通过以下代码实现∶A、在主页调用的js文件末尾加上以下代码var getParam = function(name){var search = document.location.search;var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");var matcher = pattern.exec(search);var items = null;if(null != matcher){try{items =decodeURIComponent(decodeURIComponent(matcher[1]));}catch(e){try{items = decodeURIComponent(matcher[1]);}catch(e){items = matcher[1];}}}return items;};pc=getParam('pc'); /*以上是获取url参数pc的值,包括null*//*alert(pc);*//*alert(getParam('pc'));*/var is_iPd = erAgent.match(/(iPad|iPod|iPhone)/i) != null; var is_mobi =erAgent.toLowerCase().match(/(ipod|iphone|android|coolpad |mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|win ce)/i) != null;if((is_mobi && window.location.search.indexOf("mv=fp")<0) &&(pc==null)){window.location.href="/wap/"; /*此处的wap为你的手机网址文件夹或url*/}B、在触屏版的footer代码中加上以下代码<a href="../?pc=1">电脑版</a>通过pc变量来判断用户是初始访问网址还是通过触屏版访问网址。
最全的网页自动跳转代码方法

最全的网页自动跳转代码方法
日期:16-08-09 作者:八梦网络工作室来源:原创
网页自动跳转代码方法很多,在这里厦门网站建设小编-云端网络专门为大家收集整理了最全的网页自动跳转代码方法,希望可以帮助大家实现网页自动跳转。
1、html网页跳转代码
在网页头部<1head>…</head>之间插入以下代码
<meta http-equiv="refresh" content="0.1;url=">,其中: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: ");。
JS脚本根据手机浏览器类型跳转WAP手机网站(两种方式)

JS脚本根据⼿机浏览器类型跳转WAP⼿机⽹站(两种⽅式)随着移动互联⽹的不断普及,企业的⽹络宣传不仅只局限在PC端,还要在移动端发展。
我们在⾃⼰的⽹站做了WAP⼿机完整之后,如果有⽤户通过⼿机访问我们的企业顶级域名⽹站,就要判断跳转到专为的WAP⽹站,下⾯⼩编通过两种⽅式介绍根据⼿机浏览器类型跳转WAP⼿机⽹站,具体内容如下。
第⼀种⽅式:直接JS脚本<script type="text/javascript">try {var urlhash = window.location.hash;if (!urlhash.match("fromapp")){if ((erAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))){window.location="(更换成⾃⼰的WAP⽹站)";}}}catch(err){}</script>第⼆种⽅式,稍微长⼀些,引⽤function uaredirect(murl){try {if(document.getElementById("bdmark") != null){return;}var urlhash = window.location.hash;if (!urlhash.match("fromapp")){if ((erAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))) {location.replace(murl);}}} catch(err){}}上述的脚本保持到mobile.js⽂件,然后在需要调⽤的页⾯引⽤下⾯2个JS调⽤⽂件。
复制代码代码如下:<script src="mobile.js" type="text/javascript"></script><script type="text/javascript">uaredirect("(更换成⾃⼰的WAP⽹站)");</script>两种⽅法都可以使⽤,我在安卓和IPHONE测试可⾏。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
<?php
//php判断客户端是否为手机
$agent = $_SERVER['HTTP_USER_AGENT'];
if(strpos($agent,"NetFront") || strpos($agent,"iPhone") || strpos($agent,"MIDP-2.0") || strpos($agent,"Opera Mini") || strpos($agent,"UCWEB") || strpos($agent,"Android") || strpos($agent,"Windows CE") || strpos($agent,"SymbianOS"))
header("Location:xxxxxxxx");
?>
JS判断
<script type=”text/javascript”>
<!—
//平台、设备和操作系统
var system ={
win : false,
mac : false,
xll : false
};
//检测平台
var p = navigator.platform;
system.win = p.indexOf(“Win”) == 0;
system.mac = p.indexOf(“Mac”) == 0;
system.x11 = (p == “X11”) || (p.indexOf(“Linux”) == 0);
//跳转语句
if(system.win||system.mac||system.xll){
}else{
window.location.href=”wap.asp”;
}
—>
</script>
百度APP的跳转代码。
function uaredirect(murl){
try {
if(document.getElementById("bdmark") != null){
return;
}
var urlhash = window.location.hash;
if (!urlhash.match("fromapp")){
if ((erAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))) {
location.replace(murl);
}
}
} catch(err){}
}
把上面的代码命名为:mobile.js
然后把下面的两段JS添加到首页的头部。
<script src="/mobile.js" type="text/javascript"></script>
<script type="text/javascript">uaredirect("/wap.php");</script>
1 2 3 4 5 6 7 8 9
10
11
12
13
14
15
16
17
18
19
20
21
22 <script type="text/javascript">
<!--
//平台、设备和操作系统
var system ={
win : false,
mac : false,
xll : false
};
//检测平台
var p = navigator.platform;
alert(p);
system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); //跳转语句
if(system.win||system.mac||system.xll){//转向后台登陆页面
window.location.href="login.jsp";
}else{
window.location.href="wapLojin.jsp";
}
-->
</script>。