什么是 iOS 5.0 用户代理字符串?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7825873/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the iOS 5.0 user agent string?
提问by chown
What is the iOS 5.0user agent string?
什么是iOS 5.0用户代理字符串?
Here is the iOS 4.0user agent: What is the iPhone 4 user-agent?
这是iOS 4.0用户代理:什么是 iPhone 4 用户代理?
回答by chown
iPhone:
苹果手机:
Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
iPad:
iPad:
Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
回答by Nate
This site seems to keep a complete list that's still maintained
该站点似乎保留了一个完整的列表,该列表仍在维护中
iPhone, iPod Touch, and iPad from iOS 2.0 - 5.1.1(to date).
iPhone、iPod Touch 和 iPad 从 iOS 2.0 - 5.1.1(至今)。
You do need to assemble the full user-agent string out of the information listed in the page's columns.
您确实需要从页面列中列出的信息中组合出完整的用户代理字符串。
回答by Andrew Steitz
I found a more complete listing at user agent string. BTW, this site has more than just iOS user agent strings. Also, the home page will "break down" the user agent string of your current browser for you.
我在用户代理字符串中找到了更完整的列表。顺便说一句,这个网站不仅仅是 iOS 用户代理字符串。此外,主页将为您“分解”当前浏览器的用户代理字符串。
回答by Geek Devigner
fixed my agent string evaluation by scrubbing the string for LOWERCASE "iphone os 5_0" as opposed to "iPhone OS 5_0." now i am properly assigning iOS 5 specific classes to my html, when the uppercase scrub failed.
通过清除LOWERCASE“iphone os 5_0”而不是“iPhone OS 5_0”的字符串来修复我的代理字符串评估。现在,当大写擦洗失败时,我正在将 iOS 5 特定类正确分配给我的 html。
回答by fulvio
I use the following to detect different mobile devices, viewport and screen. Works quite well for me, might be helpful to others:
我使用以下来检测不同的移动设备、视口和屏幕。对我来说效果很好,可能对其他人有帮助:
var pixelRatio = window.devicePixelRatio || 1;
var viewport = {
width: window.innerWidth,
height: window.innerHeight
};
var screen = {
width: window.screen.availWidth * pixelRatio,
height: window.screen.availHeight * pixelRatio
};
var iPhone = /iPhone/i.test(navigator.userAgent);
var iPhone4 = (iPhone && pixelRatio == 2);
var iPhone5 = /iPhone OS 5_0/i.test(navigator.userAgent);
var iPad = /iPad/i.test(navigator.userAgent);
var android = /android/i.test(navigator.userAgent);
var webos = /hpwos/i.test(navigator.userAgent);
var iOS = iPhone || iPad;
var mobile = iOS || android || webos;
window.devicePixelRatio
is the ratio between physical pixels and device-independent pixels (dips) on the device.
window.devicePixelRatio
= physical pixels / dips.
window.devicePixelRatio
是设备上物理像素与设备无关像素(下降)之间的比率。
window.devicePixelRatio
= 物理像素/下降。
More info here.
更多信息在这里。