SoFunction
Updated on 2025-03-01

JS realizes the function of judging the mobile PC side

This article mainly introduces JS to determine the function of mobile PC. The article introduces the example code in detail, which has certain reference value for everyone's learning or work. Friends who need it can refer to it.

The elf on the blog looks very durable. It has been two years since I realized that it will block the screen if I watch it on the mobile terminal. Since I know, I need to improve it.

Determine whether it is a PC or a mobile terminal

function IsPC() {
  var userAgentInfo = ;
  var Agents = ["Android", "iPhone","SymbianOS", "Windows Phone","iPad", "iPod"];
  var flag = true;
  for (var v = 0; v < ; v++) {
    if ((Agents[v]) > 0) {
      flag = false;
      break;
    }
  }
  return flag;
}

or

if (/(iPhone|iPad|iPod|iOS|Android)/()) { //Mobile terminal//TODO
}

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.