導航:首頁 > 編程語言 > 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判斷移動設備跳轉相關的資料

熱點內容
美版a1453是什麼版本 瀏覽:517
電腦里的文件夾按照拼音歸類 瀏覽:996
文件管理器怎麼把視頻壓縮成文件 瀏覽:477
標准化文件名稱包括哪些 瀏覽:85
win10不能讀取dll文件 瀏覽:882
雲騎士重裝系統找不到usb字樣文件 瀏覽:42
皖事通app社保年限在哪裡看 瀏覽:65
為什麼快影顯示沒網路 瀏覽:356
華為如何讓手機升級提醒紅1消失 瀏覽:345
我愛九九商城app 瀏覽:587
劍靈蒼穹武器升級 瀏覽:248
微信錢包微粒貸 瀏覽:654
滾動字幕屏找不到文件 瀏覽:990
鄭州青少年學編程哪個機構比較好 瀏覽:866
ps文件打開不是彩色的 瀏覽:781
監控硬碟格式化工具 瀏覽:512
下載新版本微信6311 瀏覽:440
有哪些手游可以鍛煉編程能力 瀏覽:602
網路高清監控安裝方法 瀏覽:165
linuxtty切換 瀏覽:966

友情鏈接