導航:首頁 > 編程語言 > js判斷移動設備跳轉

js判斷移動設備跳轉

發布時間:2023-06-16 12:12:02

① 怎麼用js代碼識別手機和電腦然後讓他們跳轉到各自的網頁

只要在來要跳轉的源頁面head標簽里加上下面這句代碼就行了

<scriptsrc="http://siteapp..com/static/webappservice/uaredirect.js"type="text/javascript"></script>
<scripttype="text/javascript">
uaredirect("手機版頁面網址");
</script>

② js判斷手機還是電腦,然後實現a標簽的鏈接跳轉

function IsPC() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}

通過flag來進行賦版值權

③ 如何用js來指定頁面進行判斷當前是pc端還是移動端來跳轉不同的首頁

function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for (var v = 0; v < Agents.length; v++) { if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } } return flag;}

④ 如何在js文件設置判斷手機端跳轉

<scriptlanguage="JavaScript">
functionmobile_device_detect(url){
varthisOS=navigator.platform;
varos=newArray("iPhone","iPod","iPad","android","Nokia","SymbianOS","Symbian","WindowsPhone","Phone","linuxarmv71","MAUI","UNTRUSTED/1.0","WindowsCE","BlackBerry","IEMobile");
for(vari=0;i<os.length;i++){
if(thisOS.match(os[i])){
window.location=url;
}

}
//因為相當部分的手機系統不知道信息,這里是做臨時性特殊辨認
if(navigator.platform.indexOf('iPad')!=-1){
window.location=url;
}
//做這一部分是因為Android手機的內核也是Linux
//但是navigator.platform顯示信息不盡相同情況繁多,因此從瀏覽器下手,即用navigator.appVersion信息做判斷
varcheck=navigator.appVersion;
if(check.match(/linux/i)){
//X11是UC瀏覽器的平台,如果有其他特殊瀏覽器也可以附加上條件
if(check.match(/mobile/i)||check.match(/X11/i)){
window.location=url;
}
}
//類in_array函數
Array.prototype.in_array=function(e){
for(i=0;i<this.length;i++){
if(this[i]==e)returntrue;
}
returnfalse;
}
}
mobile_device_detect("需要跳轉的手機網址");
</script>

⑤ php或js如何判斷: 當電腦訪問手機頁面時自動跳轉到PC版網頁!

<script type="text/javascript">
function IsPhone() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
var flag = false;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = true;
break;
}
}
return flag;
}
if (IsPhone()) {
window.location ="http://m..com";
};
</script>
這是如果是手機訪問跳轉到m..com,如果是要匹配pc的話 改false和true就行

⑥ js判斷是手機訪問還是電腦訪問自動跳轉

|<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>

⑦ 求一段js 判斷設備跳轉網頁的代碼

var userAgentInfo = navigator.userAgent;
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var flag = false;
var v=0
for ( v = 0; v < Agents.length; v++)
{
if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = true; break; }
}
if(flag){
回alert(Agents[v]);// 設備類答型
}
else
{
// pc
}

⑧ 網頁代碼 JS代碼 檢測手機或是Pad設備 是否安裝某軟體 之後做相應的跳轉

簡單來說就是運行在移動端瀏覽器上的網站。不管應用在什麼地方,總之就是瀏覽器唄,可以通過JS來判斷本地是否有某應用,實現方式實際就是將http協議轉為本地軟體協議。

如下:

<script language="javascript">
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
var loadDateTime = new Date();
window.setTimeout(function() {
var timeOutDateTime = new Date();
if (timeOutDateTime - loadDateTime < 5000) {
window.location = "要跳轉的頁面URL";
} else {
window.close();
}
},
25);
window.location = " apps custom url schemes ";
} else if (navigator.userAgent.match(/android/i)) {
var state = null;
try {
state = window.open("apps custom url schemes ", '_blank');
} catch(e) {}
if (state) {
window.close();
} else {
window.location = "要跳轉的頁面URL";
}
}
</script>

apps custom url schemes 是什麼呢?
其實就是你與APP約定的一個協議URL,你的IOS同事或Android同事在寫程序的時候會設置一個URL Scheme,
例如設置:
URL Scheme :app
然後其他的程序就可以通過URLString = app:// 調用該應用。

還可以傳參數,如:

app://reaction/?uid=1
原理:500ms內,本機有應用程序能解析這個協議並打開程序,調用該應用;如果本機沒有應用程序能解析該協議或者500ms內沒有打開這個程序,則執行setTimeout裡面的function,就是跳轉到你想跳轉的頁面。

閱讀全文

與js判斷移動設備跳轉相關的資料

熱點內容
雜志版本號是什麼意思 瀏覽:223
地圖特效代碼 瀏覽:192
去除思科配置文件中的號 瀏覽:196
運行的16位程序太多 瀏覽:1
蘋果mac用什麼軟體好學編程 瀏覽:681
ai中線段怎麼添加寬度配置文件 瀏覽:956
lol文件怎麼找不到game 瀏覽:142
aecc視頻教程 瀏覽:983
linux怎麼查看資料庫用戶名 瀏覽:182
cefs文件系統 瀏覽:404
學平面設計個編程哪個好 瀏覽:701
如何把編程文件轉為hex 瀏覽:80
清除蘋果地圖來自地址 瀏覽:233
已經打開的文件如何清理 瀏覽:685
視頻網站有什麼用 瀏覽:70
多個表格文件怎樣壓縮文件 瀏覽:729
cad文件大很卡如何解決 瀏覽:633
將java程序打包成apk 瀏覽:277
2021唱吧文件找不到了 瀏覽:463
華為p9手機文件管理 瀏覽:284

友情鏈接