用js判断是widows还是linux,JS 如何判断浏览器是安卓还是苹果

您所在的位置:网站首页 如何判断是安卓还是苹果 用js判断是widows还是linux,JS 如何判断浏览器是安卓还是苹果

用js判断是widows还是linux,JS 如何判断浏览器是安卓还是苹果

2023-07-24 04:02| 来源: 网络整理| 查看: 265

c8cf33fe88958e9c0687c3c32e3ce393.png摘要:

js 对客户端的操作系统进行判断主要用:navigator.userAgent、navigator.platform。用 navigator.userAgent 判断 &...

js 对客户端的操作系统进行判断主要用:navigator.userAgent、navigator.platform。

用 navigator.userAgent 判断if(/android/i.test(navigator.userAgent)){

document.write("This is Android'browser.");//这是Android平台下浏览器

}

if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)){

document.write("This is iOS'browser.");//这是iOS平台下浏览器

}

if(/Linux/i.test(navigator.userAgent)){

document.write("This is Linux'browser.");//这是Linux平台下浏览器

}

if(/MicroMessenger/i.test(navigator.userAgent)){

document.write("This is MicroMessenger'browser.");//这是微信平台下浏览器

}

用 navigator.platform 判断if(/Win/i.test(navigator.platform)){

document.write("这是Windows操作系统平台");

}

if(/Mac/i.test(navigator.platform)){

document.write("这是Mac操作系统平台");

}

if(/Linux/i.test(navigator.platform)){

document.write("这是Linux操作系统平台(包括安卓系统)");

}

if(/iOS/i.test(navigator.platform)){

document.write("这是iOS操作系统平台");

}



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3