CodePudding user response:
Actually do you think so, which one do you want to judge, completely. You can also use the navigator userAgent to judge the current device is a mobile or PCCodePudding user response:
Determine what is the current equipmentCodePudding user response:
Online is not have a lot of chestnut, all can be judged by the mobile terminal or PC into the pageCodePudding user response:
Use the bootstrap adaptiveCodePudding user response:
The function IsPC () {Var userAgentInfo=the navigator. UserAgent;
Var Agents=[" Android ", "iPhone",
"SymbianOS", "Windows Phone",
"Apple", "iPod"];
var flag=true;
For (var v=0; V & lt; Agents. Length; V++) {
If (userAgentInfo. IndexOf (Agents [v]) & gt; 0 {
flag=false;
break;
}
}
Return flag;
};
CodePudding user response:
Browser is according to the navigator userAgent to match the mobile phone system, the code is as follows:
The function getPlatform () {
Let platform, flag=true, u=the navigator. UserAgent;
Let the config=[
'android'
'iPhone'
'iPod'
'the ios'
'the',
'the Symbian,
'Windows',
]//platform is not very full, add your own
InitPlatform (config);
The function initPlatform (o) {
For (in the let k o {
Let reg=eval (`/${o} [k]/I `);
If (u.m atch (reg)) {
flag=false;
Platform [type]=o [k].
break;
}
}
}
Flag & amp; &='PC' (platform)
The return of platform;
}