当前位置:网站首页>JS simple code determines whether the device that opens the page is the PC end of the computer, the H5 end of the mobile phone, or the wechat end
JS simple code determines whether the device that opens the page is the PC end of the computer, the H5 end of the mobile phone, or the wechat end
2022-07-29 05:38:00 【coderYYY】
// First judge whether the wechat terminal is opened
if (/(micromessenger)/i.test(navigator.userAgent)) {
alert(" WeChat ");
} else {
alert(" Normal browser ");
// Judge h5 still pc
let client =
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
);
if (client) {
alert("h5");
} else {
alert("pc");
}
}
边栏推荐
猜你喜欢
随机推荐
Storage category
uniapp组件之tab选项卡滑动切换
HCIA-R&S自用笔记(25)NAT技术背景、NAT类型及配置
【C语言系列】— 字符串+部分转义字符详解+注释小技巧
Day 2
第三课threejs全景预览房间案例
End of document
Clickhouse learning (IV) SQL operation
小程序中的DOM对象元素块动态排序
Application of Huffman tree and Huffman coding in file compression
第一周总结
link与@import导入外部样式的区别
ClickHouse学习(一)ClickHouse?
无重复字符的最长字串
JS deep copy - Notes
B - identify floating point constant problems
rem与px与em异同点
相对定位和绝对定位
微信小程序视频上传组件直接上传至阿里云OSS
微信小程序-屏幕高度