JS判断移动设备并跳转至手机版网页代码
1,使用 userAgent 判断,并跳转。
<script type=”text/javascript”> if((/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) )) {window.location = "网页地址";} </script>
2,使用 Device.js 库 判断设备,并跳转。
Device.js: https://github.com/matthewhudson/device.js
Brower : bower install devicejs
<script> if(device.mobile()){window.location = "网页地址";} </script>
Device 下面有很多设备样式名。
Categories:
html.css.js
已禁用评论。