开发者

What is the best way to determine if a web-page is for mobile?

开发者 https://www.devze.com 2023-01-08 03:47 出处:网络
Should I scan for tags in the html code? Or what? What determines whether a page is optimized for mobile?

Should I scan for tags in the html code? Or what? What determines whether a page is optimized for mobile?

One option is to scan for tags. If so, what other tags are there?

<link rel="apple-touch-icon" href="..." />
<meta name="viewport" content="width=device-width, user-scalable=no" />

Another option is to see if the HTML returned from a mobile user-agent is smaller than the HTML returned from a desktop browser. user agent...

Any tho开发者_开发问答ughts?


One option: look for: <meta name="MobileOptimized" />

Another: <meta name="HandheldFriendly" content="true"/>

Another: doctype is either XHTML-MP or WML (or other mobile-friendlies).


Here's a usefuil link for sniffing out different smartphones using JavaScript.

http://www.hand-interactive.com/resources/detect-mobile-javascript.htm

However, its worth paying attention to the caveats in the above link. Particularly, the fact that we are browser sniffing, which is inherently unreliable (I recently got a hit on my website for MSIE 999.1)


What exactly are you trying to accomplish?

Officially, there is no such thing as a mobile page. It's perfectly possible to create a page that works equally well on mobile as on desktop browsers. Hell, if you just make a page with simple html and no styling it will already do that.

These days we often see seperate mobile pages, but usually this is an indicator that the design of the 'normal' page was not thought-through.

Long story short, you could never detect this 100% because there's no real difference.


If you want to find out whether or not a browser is mobile or not, check this out: http://wapl.info/coding-for-the-mobile-web-with-WAPL/chapter/isMobileDevice-via-CURL/

Pass through all of your headers, and the web service will do the rest.

Better than detecting mobile with javascript, or looking for specific tags - do it before you even start outputting anything to the screen.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号