<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>mocreative &#187; 设备侦测</title>
	<atom:link href="http://mocreative.net/tag/%e8%ae%be%e5%a4%87%e4%be%a6%e6%b5%8b/feed/" rel="self" type="application/rss+xml" />
	<link>http://mocreative.net</link>
	<description>移动web设计</description>
	<lastBuildDate>Wed, 07 Jul 2010 16:08:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>诺基亚开发者论坛：跨浏览器指南</title>
		<link>http://mocreative.net/news/cross-browser-guidlines/</link>
		<comments>http://mocreative.net/news/cross-browser-guidlines/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 01:04:34 +0000</pubDate>
		<dc:creator>五梭</dc:creator>
				<category><![CDATA[新闻]]></category>
		<category><![CDATA[设计]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[用户体验]]></category>
		<category><![CDATA[设备侦测]]></category>

		<guid isPermaLink="false">http://mocreative.net/?p=58</guid>
		<description><![CDATA[Forum Nokia发布了一个关于浏览器兼容的文档。描述了如何为iPhone、Maemo、Android和部分S60触摸设备优化自己的网站。里面有很多有用的小提示和建议值得参考。另外，压缩包内还提供了一些基于诺基亚高端设备移动Web模版创建的示例。最后的参考资料也非常精彩。]]></description>
			<content:encoded><![CDATA[<p>Forum Nokia<a href="http://www.forum.nokia.com/info/sw.nokia.com/id/1042e49c-15b6-4d83-8c4f-d9227ceabd2c/Cross-Browser_Guidelines_v1_0_en.zip.html" class="liexternal">发布了一个关于浏览器兼容的文档</a>。描述了如何为iPhone、Maemo、Android和部分S60触摸设备优化自己的网站。里面有很多有用的小提示和建议值得参考。另外，压缩包内还提供了一些基于诺<a href="http://www.forum.nokia.com/Technology_Topics/Web_Technologies/Browsing/Web_Templates/Templates_for_High-End_Devices/" class="liexternal">基亚高端设备移动Web模版</a>创建的示例。<a href="http://sw.nokia.com/id/1042e49c-15b6-4d83-8c4f-d9227ceabd2c/Cross-Browser_Guidelines_v1_0_en.zip" title="诺基亚跨浏览器指南" class="lizip">可以在这里下载</a>。最后的参考资料也非常精彩。</p>
]]></content:encoded>
			<wfw:commentRss>http://mocreative.net/news/cross-browser-guidlines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPad的CSS3媒体查询</title>
		<link>http://mocreative.net/design/ipad-media-query/</link>
		<comments>http://mocreative.net/design/ipad-media-query/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 01:40:47 +0000</pubDate>
		<dc:creator>五梭</dc:creator>
				<category><![CDATA[设计]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[用户体验]]></category>
		<category><![CDATA[设备侦测]]></category>

		<guid isPermaLink="false">http://mocreative.net/?p=56</guid>
		<description><![CDATA[iPad的Safari浏览器和iPhone的一样，都支持CSS3媒体查询。通过这个技术，可以对设备不同的握持方向应用不同的样式，增强功能和体验。iPhone是通过屏幕最大宽度来侦测的。而iPad有点不同，它直接使用了媒体查询中的orientation属性。]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.apple.com/ipad" title="ipad官方" class="liexternal">iPad</a>的Safari浏览器和iPhone的一样，都支持<a href="http://www.w3.org/TR/css3-mediaqueries/" title="CSS3媒体查询" class="liexternal">CSS3媒体查询</a>。通过这个技术，可以对设备不同的握持方向应用不同的样式，增强功能和体验。iPhone是通过屏幕最大宽度来侦测的。是这样：</p>
<p><code>&lt;link rel="stylesheet" media="screen and (max-width: 320px)" href="portrait.css" /&gt;<br />
&lt;link rel="stylesheet" media="screen and (min-width: 321px)" href="landscape.css" /&gt;</code></p>
<p>而iPad有点不同，它直接使用了媒体查询中的orientation属性。是这样：</p>
<p><code>&lt;link rel="stylesheet" media="screen and (orientation:portrait)" href="portrait.css" /&gt;<br />
&lt;link rel="stylesheet" media="screen and (orientation:landscape)" href="landscape.css" /&gt;</code></p>
<p>之后只要将不同的样式分别定义出来就可以了。在桌面平台测试的话，firefox，Safari和Chrome都支持方向属性，只需要改变窗口让高度大于宽度，就会识别为纵向屏幕。</p>
<p><a href="http://www.cloudfour.com/ipad-orientation-css/" title="cloudfour ipad media query" class="liexternal">Cloud Four Blog的文章</a>里有制作一个例子，可以去<a href="http://www.cloudfour.com/ipad-css/" title="测试方向" class="liexternal">试试看</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://mocreative.net/design/ipad-media-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10条小代码开发iPhone友好的网站</title>
		<link>http://mocreative.net/design/10-snippets-iphone-friendly/</link>
		<comments>http://mocreative.net/design/10-snippets-iphone-friendly/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 03:39:58 +0000</pubDate>
		<dc:creator>五梭</dc:creator>
				<category><![CDATA[设计]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[设备侦测]]></category>

		<guid isPermaLink="false">http://mocreative.net/?p=29</guid>
		<description><![CDATA[如果要针对iPhone/iPod Touch开发移动网站，以下十条小代码几乎肯定是需要用到的，方便又有效。可以做到侦测iPhone/iPod、设置viewpoint和屏幕等宽、使用iPhone规格图标、侦测设备旋转方向、隐藏工具栏和模拟:hover伪类等。]]></description>
			<content:encoded><![CDATA[<p>如果要针对iPhone/iPod Touch开发移动网站，以下十条小代码几乎肯定是需要用到的，方便又有效。</p>
<h3>侦测iPhone/iPod</h3>
<p>开发特定设备的移动网站，首先要做的就是设备侦测了。下面是使用Javascript侦测iPhone/iPod的UA，然后转向到专属的URL。</p>
<p><code>if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {<br />
if (document.cookie.indexOf("iphone_redirect=false") == -1) {<br />
window.location = "http://m.espn.go.com/wireless/?iphone&amp;i=COMR";<br />
}<br />
}</code></p>
<p>虽然Javascript是可以在水果设备上运行的，但是用户还是可以禁用。它也会造成客户端刷新和额外的数据传输，所以下面是服务器端侦测和转向：</p>
<p><code>if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) {<br />
header('Location: http://yoursite.com/iphone');<br />
exit();<br />
}</code></p>
<h3>设置viewpoint和屏幕等宽</h3>
<p>如果不设置viewpoint，网站在viewpoint就会显示成缩略形式。如果你专门为iPhone/iPod开发网站，这一条很有用，而且很简单，只需要插入到head里就可以：</p>
<p><code>&lt;meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"&gt;</code></p>
<h3>使用iPhone规格图标</h3>
<p>如果你的用户将你的网站添加到home screen，iPhone会使用网站的缩略图作为图标。然而你可以提供一个自己设计的图标，这样当然更好。图片是57&#215;57大小，png格式。不需要自己做圆角和反光，系统会自动完成这些工作。然后将下面这条加入head中：</p>
<p><code>&lt;rel="apple-touch-icon" href="images/youricon.png"/&gt;</code></p>
<h3>阻止旋转屏幕时自动调整字体大小</h3>
<p><code>-webkit-text-size-adjust</code>是webkit的私有css：</p>
<p><code>html, body, form, fieldset, p, div, h1, h2, h3, h4, h5, h6 {-webkit-text-size-adjust:none;}</code></p>
<h3>侦测设备旋转方向</h3>
<p>iPhone可以在横屏状态下浏览网页，有时候你会想知道用户设备的手持状态来增强可用性和功能。下面一段Javascript可以判断出设备向哪个方向旋转，并且替换css：</p>
<p><code>window.onload = function initialLoad() {updateOrientation();}</code></p>
<p>function updateOrientation(){<br />
var contentType = &#8220;show_&#8221;;<br />
switch(window.orientation){<br />
case 0:<br />
contentType += &#8220;normal&#8221;;<br />
break;</p>
<p>case -90:<br />
contentType += &#8220;right&#8221;;<br />
break;</p>
<p>case 90:<br />
contentType += &#8220;left&#8221;;<br />
break;</p>
<p>case 180:<br />
contentType += &#8220;flipped&#8221;;<br />
break;<br />
}<br />
document.getElementById(&#8220;page_wrapper&#8221;).setAttribute(&#8220;class&#8221;, contentType);<br />
}</p>
<h3>iPhone才识别的CSS</h3>
<p>如果不想设备侦测，可以用CSS媒体查询来专为iPhone/iPod定义样式。</p>
<p><code>@media screen and (max-device-width: 480px) {}</code></p>
<h3>缩小图片</h3>
<p>网站的大图通常宽度都超过480像素，如果用前面的代码限制了缩放，这些图片在iPhone版显示显然会超过屏幕。好在iPhone机能还够，我们可以用CSS让iPhone自动将大图片缩小显示。</p>
<p><code>@media screen and (max-device-width: 480px){<br />
img{max-width:100%;height:auto;}<br />
}</code></p>
<p>注意如果原图片非常大，或一个页面非常多图，最好还是在服务器端缩放到480像素宽，iPhone只需要在正常浏览时缩略到320像素。这样不会消耗太多流量和机能。</p>
<h3>默认隐藏工具栏</h3>
<p>iPhone的浏览器工具栏会在页面最顶端，卷动网页后才隐藏。这样在加载网页完成后显得很浪费空间，特别是横向屏幕时。我们可以让它自动卷动上去。</p>
<p><code>window.addEventListener('load', function() {<br />
setTimeout(scrollTo, 0, 0, 1);<br />
}, false);</code></p>
<h3>使用特殊链接</h3>
<p>这两条不用说了吧：</p>
<p><code>&lt;a href="tel:12345678900"&gt;打电话给我&lt;/a&gt;<br />
&lt;a href="sms:12345678900"&gt;发短信&lt;/a&gt;</code></p>
<h3>模拟:hover伪类</h3>
<p>因为iPhone并没有鼠标指针，所以没有hover事件。那么CSS :hover伪类就没用了。但是iPhone有Touch事件，onTouchStart 类似 onMouseOver，onTouchEnd 类似 onMouseOut。所以我们可以用它来模拟hover。使用Javascript：</p>
<p><code>var myLinks = document.getElementsByTagName('a');<br />
for(var i = 0; i &lt; myLinks.length; i++){<br />
myLinks[i].addEventListener(’touchstart’, function(){this.className = “hover”;}, false);<br />
myLinks[i].addEventListener(’touchend’, function(){this.className = “”;}, false);<br />
}</code></p>
<p>然后用CSS增加hover效果：</p>
<p><code>a:hover, a.hover { /* 你的hover效果 */ }</code></p>
<p>这样设计一个链接，感觉可以更像按钮。并且，这个模拟可以用在任何元素上。</p>
<h3>参考资料：</h3>
<p><a href="http://csswizardry.com/2010/01/iphone-css-tips-for-building-iphone-websites/" class="liexternal">iPhone CSS—tips for building iPhone websites</a></p>
<p><a href="http://davidwalsh.name/detect-iphone" class="liexternal">iPhone &amp; iPod Detection Using Javascript</a></p>
<p><a href="http://articles.sitepoint.com/article/iphone-development-12-tips/" class="liexternal">iPhone Development: 12 Tips To Get You Started</a></p>
<p><a href="http://www.engageinteractive.co.uk/blog/2008/06/19/tutorial-building-a-website-for-the-iphone/" title="Permanent Link: Tutorial: Building a website for the iPhone" rel="bookmark" class="liexternal">Tutorial: Building a website for the iPhone</a></p>
<p><a href="http://www.evotech.net/blog/2008/12/hover-pseudoclass-for-the-iphone/" rel="bookmark" class="liexternal">hover pseudoclass for the iPhone</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mocreative.net/design/10-snippets-iphone-friendly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>设备侦测在云端：DeviceAtlas 个人版</title>
		<link>http://mocreative.net/design/deviceatlas-personal/</link>
		<comments>http://mocreative.net/design/deviceatlas-personal/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 08:15:02 +0000</pubDate>
		<dc:creator>五梭</dc:creator>
				<category><![CDATA[设计]]></category>
		<category><![CDATA[设备侦测]]></category>

		<guid isPermaLink="false">http://mocreative.net/?p=34</guid>
		<description><![CDATA[什么是DeviceAtlas？它是mtld开发者论坛的一个设备描述数据库，可以用做设备侦测。DeviceAtlas个人版是DeviceAtlas简化版本，让人们能更容易的侦测设备。两者的不同在于，个人版是一种web服务，它不需要安装任何程序，也不用升级设备数据库，它是这样工作的：一位用户用他的移动设备访问我们你的网站，网站将HTTP请求头信息的User-Agent发送到DA个人版服务，我们网站收到的回应就包含了用户的设备信息。就这么简单！
http://mobiforge.com/developing/story/device-detection-cloud-deviceatlas-personal
注：目前这个服务是预览版，所以DA并不保证稳定。 而且目前仅基于UA字串，将来也会支持UAProf。
]]></description>
			<content:encoded><![CDATA[<p>什么是DeviceAtlas？它是mtld开发者论坛的一个设备描述数据库，可以用做设备侦测。DeviceAtlas个人版是DeviceAtlas简化版本，让人们能更容易的侦测设备。两者的不同在于，个人版是一种web服务，它不需要安装任何程序，也不用升级设备数据库，它是这样工作的：一位用户用他的移动设备访问我们你的网站，网站将HTTP请求头信息的User-Agent发送到DA个人版服务，我们网站收到的回应就包含了用户的设备信息。就这么简单！</p>
<p><a href="http://mobiforge.com/developing/story/device-detection-cloud-deviceatlas-personal" class="liexternal">http://mobiforge.com/developing/story/device-detection-cloud-deviceatlas-personal</a></p>
<p>注：目前这个服务是预览版，所以DA并不保证稳定。 而且目前仅基于UA字串，将来也会支持UAProf。</p>
]]></content:encoded>
			<wfw:commentRss>http://mocreative.net/design/deviceatlas-personal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
