There are lots of scripts for detecting the User Agent string to detect iPhones and other mobile devices, but strangely enough, the iPhone 4's UA is the same as other versions.
My webapp has many 开发者_运维百科HTML5 features that need to be displayed differently for the 326ppi screen than other resolutions.
Thanks in advance for any insight.
Another technique I came across was to check for the device width with the user agent:
var iphone4 = navigator.userAgent.match(/iPhone/i) !== null && window.screen.height == (960 / 2);
http://www.mobilexweb.com/blog/iphone4-ios4-detection-safari-viewport
iPhone useragent string:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
Can't find anything specific to iPhone 4 I'm afraid.
You could create a prompt if they are on iPhone asking them if they are on an iPhone 4 or not before the page loads, I think that is a reasonable action.
精彩评论