文章标题

来源:互联网 发布:usb数据采集模块 编辑:程序博客网 时间:2024/06/05 09:16

参考

  • http://www.shejidaren.com/the-best-way-to-detect-a-mobile-device.html

原生方法

不需要引入jQuery库,把以下代码加入到里即可。

<script type=”text/javascript”>if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {window.location = “mobile.html”; //可以换成http地址}</script>

device.js

device.js是一个用于检查设备用的插件,使用它你可以很方便的判断设备的操作系统,以及设备是纵向还是横向。

下载地址: https://github.com/matthewhudson/device.js

使用时先引入插件,然后加入判断代码

<script type=”text/javascript”>if(device.mobile()){window.location = “shouji.html”;  //可以换成http地址}</script>

Device.js 方法有很多,若你想实现对某个设备的判断,要以根据以下代码来替换device.mobile()。

image

0 0
原创粉丝点击