當前位置:首頁 » 密碼管理 » 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 瀏覽:55
189郵箱伺服器地址 發布:2025-09-06 05:11:32 瀏覽:99
山東淘寶網店拍攝腳本 發布:2025-09-06 05:09:34 瀏覽:42
輕量伺服器怎麼看ip 發布:2025-09-06 04:12:01 瀏覽:224
linuxtomcat項目 發布:2025-09-06 04:07:06 瀏覽:824
vivox7怎麼清除緩存 發布:2025-09-06 04:05:44 瀏覽:232
linqtosql多表 發布:2025-09-06 04:01:35 瀏覽:112
給內網伺服器增加ip 發布:2025-09-06 03:35:20 瀏覽:713
pc訪問跳轉代碼 發布:2025-09-06 03:24:07 瀏覽:995
停電的應急預案腳本 發布:2025-09-06 02:36:18 瀏覽:528