概述
function checkIsAppleDevice() {
var u = navigator.userAgent, app = navigator.appVersion;
var ios = !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/);
var iPad = u.indexOf('iPad') > -1;
var iPhone = u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1;
if (ios || iPad || iPhone) {
return true;
} else {
return false;
}
}
}
if (checkIsAppleDevice()) {
window.location.href = " https://itunes.apple.com/us/app/998dian-wan-cheng/id1135278767?mt=8"; / /跳转到AppStore或者Android应用市场
} else {
window.location.href = " http://mbdownload.998dw.net/998dwcPackage/android/DWC_GW.apk "; //打开apk
}
//js判断终端访问
function checkIsTerminal(){
var u = navigator.userAgent;
trident = u.indexOf('Trident') > -1;//IE内核
presto = u.indexOf('Presto') > -1;//opera内核
webkit = u.indexOf('AppleWebKit') > -1; //苹果。谷歌内核
gecko = u.indexOf('Gecko') > -1;//火狐内核
mobile= !!u.match(/AppleWebjit.*Mobile,*/);//移动终端
android = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;//Android终端
ios = !!u.match(/(i[^;]( U;)? CPU.+Mac OS X/);//ios终端
iphone = u.indexOf('iPhone') > -1;//iPhone或者QQHD浏览器
ipad = u.indexOf('iPad') > -1;//iPad
webapp = u.indexOf('Safari) == -1;//web应用程序没有头部与底部
weixin = u.indexOf('MicroMessenger') > -1;//微信
qq = u.match(/sQQ/i) == "qq";//QQ
//使用方法
if(browser.versions.trident){ alert("Is IE"); }//判断是否为IE内核
if(browser.versions.webkit){ alert(Is Webkit); }//判断是否为webKit内核
if(browser.versions.mobile || browser.versions.android || browser.versions.ios){ alert("移动端"); }//判断是否为移动端
//检测浏览器语音
currentLang = naviagtor.language;//判断除ie外其他浏览器使用语音
if(!currentLang){//判断IE浏览器语音
currentLang = navigator.browserLanguage;
}
//ios调转
if (checkIsAppleDevice()) {
window.location.href = "https://itunes.apple.com/us/app/998dian-wan-cheng/id1135278767?mt=8";//跳转到AppStore
} else {
window.location.href = "http://mbdownload.998dw.net/998dwcPackage/android/DWC_GW.apk";//打开apk
}
//ios调转
if (checkIsAppleDevice()) {
window.location.href = "https://itunes.apple.com/us/app/998dian-wan-cheng/id1135278767?mt=8";//跳转到AppStore
} else {
window.location.href = "http://mbdownload.998dw.net/998dwcPackage/android/DWC_GW.apk";//打开apk
}
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
//alert(navigator.userAgent);
window.location.href ="iPhone.html";
} else if (/(Android)/i.test(navigator.userAgent)) {
//alert(navigator.userAgent);
window.location.href ="Android.html";
} else {
window.location.href ="pc.html";
}
}
if (checkIsAppleDevice()) {
window.location.href = " https://itunes.apple.com/us/app/998dian-wan-cheng/id1135278767?mt=8"; / /跳转到AppStore
} else {
window.location.href = " http://mbdownload.998dw.net/998dwcPackage/android/DWC_GW.apk "; //打开apk
}
if (checkIsAppleDevice()) {
window.location.href = " https://itunes.apple.com/us/app/998dian-wan-cheng/id1135278767?mt=8"; / /跳转到AppStore
} else {
window.location.href = " http://mbdownload.998dw.net/998dwcPackage/android/DWC_GW.apk "; //打开apk
}
最后
以上就是轻松花瓣为你收集整理的js判断设备,跳转app应用、android市场或者AppStore的全部内容,希望文章能够帮你解决js判断设备,跳转app应用、android市场或者AppStore所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复