JS----Device.js 检测设备平台,操作系统的javascript

支持的设备有:
iOS: iPhone, iPod, iPad
Android: Phones & Tablets
Blackberry: Phones & Tablets
Windows: Phones & Tablets
Firefox OS: Phones & Tablets


使用:在head载入:<script src="device.js"></script>
它会自动在 <html> 标签添加一些设备平台,操作系统,方向相关的 CSS class,这样就能让你针对不同设备撰写不同的 CSS,并且还提供一些 Javascript 函数来判断设备
<html class="ios iphone mobile portrait">


 
生成的对比CSS Class:
		Device	CSS Classes
		iPad			ios ipad tablet
		iPhone			ios iphone mobile
		iPod			ios ipod mobile
		Android Phone	android mobile
		Android Tablet	android tablet
		BlackBerry Phone	blackberry mobile
		BlackBerry Tablet	blackberry tablet
		Windows Phone		windows mobile
		Windows Tablet		windows tablet
		Firefox OS Phone	fxos mobile
		Firefox OS Tablet	fxos tablet
		Desktop	desktop
		
	Orientation	CSS Classes
		Landscape	landscape
		Portrait	portrait


Javascript 函数

	Device	JavaScript Method
		Mobile	device.mobile()
		Tablet	device.tablet()
		iOS		device.ios()
		iPad	device.ipad()
		iPhone	device.iphone()
		iPod	device.ipod()
		Android	device.android()
		Android Phone		device.androidPhone()
		Android Tablet		device.androidTablet()
		BlackBerry			device.blackberry()
		BlackBerry Phone	device.blackberryPhone()
		BlackBerry Tablet	device.blackberryTablet()
		Windows				device.windows()
		Windows Phone		device.windowsPhone()
		Windows Tablet		device.windowsTablet()
		Firefox OS			device.fxos()
		Firefox OS Phone	device.fxosPhone()
		Firefox OS Tablet	device.fxosTablet()
	
	Orientation	JavaScript Method
		Landscape	device.landscape()
		Portrait	device.portrait()

Test:

<script src="style/js/device.js"></script>
<script>
alert(device.mobile())  //返回true, false,来判断设备
</script>

下载  Device.js


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值