Home > front end >  The judgment on the mobile end or PC
The judgment on the mobile end or PC

Time:10-10

A page can be mobile and PC, when entering a page, now is how to determine which entry? Js framework,

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 PC

CodePudding user response:

Determine what is the current equipment

CodePudding user response:

Online is not have a lot of chestnut, all can be judged by the mobile terminal or PC into the page

CodePudding user response:

Use the bootstrap adaptive

CodePudding 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;
}
  • Related