window.location.href = /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) ? 'https://www.baidu.com' : 'https://www.google.com.hk';
var isMobile = /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent);
本文提供了一段JavaScript代码示例,用于检测用户的设备是否为移动设备。通过正则表达式匹配navigator.userAgent字符串来判断设备类型,进而根据不同的设备类型跳转到相应的网站。
846

被折叠的 条评论
为什么被折叠?



