代码改变世界

针对不同的iOS设备,使用不同的CSS

2011-11-27 15:19  张智清  阅读(709)  评论(0编辑  收藏  举报

当我们知道如何在网页中检测iPhone/iPod/iPad等浏览设备时,就能够实施调用不同的CSS了,示例代码:

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
document.write('<link href="iphone.css" rel="stylesheet" type="text/css">');
}
if((navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/iPod/i))) {
document.write('<link href="ipadwoflash.css" rel="stylesheet" type="text/css">');
}