A number of iPhone apps are using JS to sniff iPhone and serve content
based on that. While I haven't seen the user agent string for the
upcoming Touch, chances are likely it will not contain
indexOf('iPhone'). This means it only takes one viewing for that new
iPod Touch user to declare that your app suxxors, et al.

Webkit.org has released a very nice detection script that is
compatible with both devices:
http://webkit.org/blog/119/webkit-detect-script-updated-for-iphone-and-ipod-touch/

But me being the ever-perfectionist iPhone developer, I've stripped
out what's not needed if all you need is i(Phone || Touch) detection:

var WebKitDetect = {
        isWebKit : function() {
                return new RegExp(" AppleWebKit/").test(navigator.userAgent);
        },
        isMobile : function() {
                return WebKitDetect.isWebKit() && new RegExp("
Mobile/").test(navigator.userAgent);
        },
        mobileDevice : function() {
                if (!WebKitDetect.isMobile()) {
                        return null;
                }
                var fields = new RegExp("(Mozilla/5.0 \\()([^;]
+)").exec(navigator.userAgent);
                if (!fields || fields.length < 3) {
                        return null;
                }
                return fields[2];
        }
};


Usage:

if (WebKitDetect.mobileDevice()) {
        setInterval(updateLayout, 400);
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to