当前位置:首页 » 密码管理 » pc访问跳转代码

pc访问跳转代码

发布时间: 2025-09-06 03:24:07

㈠ 急!!!电脑端登录手机端网站跳转电脑端的 js 脚本

主要在在于判断浏览器类型的部分
你上面已经写了“各种判断手机浏览器类型的代码”,同理
function ispc()//定义了一个判断主流pc浏览器,不全
{
var re=false;
if(navigator.userAgent.indexOf("MSIE")>0) {
re=true
}
if(navigator.userAgent.indexOf("Firefox")>0){
re=true }
if(navigator.userAgent.indexOf("Opera")>0){
re=true }
if(navigator.userAgent.indexOf("Camino")>0){
re=true }
if(navigator.userAgent.indexOf("Gecko")>0){
re=true }
return re;
}

具体执行判断代码就是 if(ispc()){
window.location.href='pc网站地址'

}

㈡ 怎样判断手机端和电脑端自动跳转到各自的页面

判断是否pc端还是wap,也可以单位写两个js文件放到wap站head里,详细步骤:

1、二者大不相同,所以用加载不同的css等方式不好实现,而我们加用下面的JS代码后,问题就变得很简单。代码1:

<script type="text/javascript">

<!--

//平台、设备和操作系统

varsystem={

win:false,

mac:false,

xll:false

};

//检测平台

varp=navigator.platform;

system.win=p.indexOf("Win")==0;

system.mac=p.indexOf("Mac")==0;

system.x11=(p=="X11")||(p.indexOf("Linux")==0);

//跳转语句,如果是手机访问就自动跳转到wap..com页面

if(system.win||system.mac||system.xll){

}else{

window.location.href="手机站链接";

}

-->

</script>

否则打开网站默认页面。

㈢ PC端访问WAP页面时自动跳转到PC版网页需要什么代码

使用以下JS函数:

functionuaredirect(f){
try{
if(document.getElementById("bdmark")!=null){
return
}
varb=false;
if(arguments[1]){
vare=window.location.host;
vara=window.location.href;
if(isSubdomain(arguments[1],e)==1){
f=f+"/#m/"+a;
b=true
}else{
if(isSubdomain(arguments[1],e)==2){
f=f+"/#m/"+a;
b=true
}else{
f=a;
b=false
}
}
}else{
b=true
}
if(b){
varc=window.location.hash;
if(!c.match("fromapp")){
if((navigator.userAgent.match(/(iPhone|iPod|Android|ios|SymbianOS)/i))){
location.replace(f)
}
}
}
}catch(d){}
}
functionisSubdomain(c,d){
this.getdomain=function(f){
vare=f.indexOf("://");
if(e>0){
varh=f.substr(e+3)
}else{
varh=f
}
varg=/^www./;
if(g.test(h)){
h=h.substr(4)
}
returnh
};
if(c==d){
return1
}else{
varc=this.getdomain(c);
varb=this.getdomain(d);
if(c==b){
return1
}else{
c=c.replace(".","\.");
vara=newRegExp("\."+c+"$");
if(b.match(a)){
return2
}else{
return0
}
}
}
};

调用方式:

<SCRIPTtype=text/javascript>uaredirect("手机站","WEB站");</SCRIPT>另外,现在分别为PC和WAP开发两个网站的做法已经不再提倡了

推荐使用响应式框架如Bootstrap等,做一个网站,同时兼容PC端和移动端
成本更低
热点内容
优酷上传清晰度 发布:2025-09-06 05:11:32 浏览:58
189邮箱服务器地址 发布:2025-09-06 05:11:32 浏览:102
山东淘宝网店拍摄脚本 发布:2025-09-06 05:09:34 浏览:45
轻量服务器怎么看ip 发布:2025-09-06 04:12:01 浏览:228
linuxtomcat项目 发布:2025-09-06 04:07:06 浏览:829
vivox7怎么清除缓存 发布:2025-09-06 04:05:44 浏览:236
linqtosql多表 发布:2025-09-06 04:01:35 浏览:116
给内网服务器增加ip 发布:2025-09-06 03:35:20 浏览:719
pc访问跳转代码 发布:2025-09-06 03:24:07 浏览:999
停电的应急预案脚本 发布:2025-09-06 02:36:18 浏览:531