javaScript client judgment

Posted May 27, 20201 min read

//Android client
const isAndroid = window.navigator.userAgent.indexOf("Android")> = 0;
//IOS client
const isIOS = /(iPhone|iPad|iPod|iOS|Mac)/i.test(navigator.userAgent);
//judgment app
const userAgent = window.navigator.userAgent;
const isApp = userAgent.indexOf("Custom Parameter")! == -1 || userAgent.search("Custom Parameter")! == -1 ||/(Custom Parameter) /. test(userAgent);
//WeChat built-in browser
const isWeChat = navigator.userAgent.match(/(MicroMessenger)/i)! == null;