TIMEX
TIMEX

Reputation: 271924

What is the best way to determine if a web-page is 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 thoughts?

Upvotes: 6

Views: 300

Answers (4)

rgubby
rgubby

Reputation: 1311

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.

Upvotes: 0

Joeri Hendrickx
Joeri Hendrickx

Reputation: 17445

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.

Upvotes: 0

Mutation Person
Mutation Person

Reputation: 30500

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)

Upvotes: 0

Tobiasopdenbrouw
Tobiasopdenbrouw

Reputation: 14039

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).

Upvotes: 2

Related Questions