JS判断移动跳转and反跳
判断是否移动端然后跳转到指定目录
<script type="text/javascript">
//手机端判断各个平台浏览器及操作系统平台
function isRedirectToMobile(){
var toMobilePage = false;
var sUserAgent = navigator.userAgent.toLowerCase();
//Android平台下浏览器
if(/android/i.test(sUserAgent)){
toMobilePage = true;
}
//iOS平台下浏览器
if(/(iPhone|iPad|iPod|iOS)/i.test(sUserAgent)){
toMobilePage = true;
}
//windows CE/MOBILE平台下浏览器
if(/(windows ce)|(windows mobile)/i.test(sUserAgent)){
toMobilePage = true;
}
//UC/UC7/浏览器
if(/(ucweb)|(rv:1.2.3.4)/i.test(sUserAgent)){
toMobilePage = true;
}
//opera浏览器
if(/Presto/i.test(sUserAgent)){
toMobilePage = true;
}
//Linux平台下浏览器
if(/Linux/i.test(sUserAgent)){
toMobilePage = true;
}
//Linux操作系统平台
if(/Linux/i.test(navigator.platform)){
toMobilePage = true;
}
//微信平台下浏览器
if(/MicroMessenger/i.test(sUserAgent)){
toMobilePage = true;
}
//执行跳转
if(toMobilePage){
window.location.href="/m/"
}
}
isRedirectToMobile();
</script>
反跳只需要把
if(toMobilePage){
window.location.href="/m/"
}
改为
if(toMobilePage==false){
window.location.href="/index.htm"
}
就可以实现在PC打开移动端跳转到PC站
aaaaaaaa