请教js如何判断是webview打开还是浏览器

2022-03-23 社会 368阅读
varos=this.os={},browser=this.browser={},
webkit=ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/),
android=ua.match(/(Android);?[\s\/]+([\d.]+)?/),
osx=!!ua.match(/\(Macintosh\;Intel/),
ipad=ua.match(/(iPad).*OS\s([\d_]+)/),
ipod=ua.match(/(iPod)(.*OS\s([\d_]+))?/),
iphone=!ipad&&ua.match(/(iPhone\sOS)\s([\d_]+)/),
webos=ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),
win=/Win\d{2}|Windows/.test(platform),
wp=ua.match(/WindowsPhone([\d.]+)/),
touchpad=webos&&ua.match(/TouchPad/),
kindle=ua.match(/Kindle\/([\d.]+)/),
silk=ua.match(/Silk\/([\d._]+)/),
blackberry=ua.match(/(BlackBerry).*Version\/([\d.]+)/),
bb10=ua.match(/(BB10).*Version\/([\d.]+)/),
rimtabletos=ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/),
playbook=ua.match(/PlayBook/),
chrome=ua.match(/Chrome\/([\d.]+)/)||ua.match(/CriOS\/([\d.]+)/),
firefox=ua.match(/Firefox\/([\d.]+)/),
firefoxos=ua.match(/\((?:Mobile|Tablet);rv:([\d.]+)\).*Firefox\/[\d.]+/),
ie=ua.match(/MSIE\s([\d.]+)/)||ua.match(/Trident\/[\d](?=[^\?]+).*rv:([0-9.].)/),
webview=!chrome&&ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/),
safari=webview||ua.match(/Version\/([\d.]+)([^S](Safari)|[^M]*(Mobile)[^S]*(Safari))/)
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com