Sencha Environment Detection答案通过简单的手段提供了一个大范围。
而不是Ext.os.is.Tablet,你可以通过Ext.os.deviceType将返回生活更轻松:
注意:通过将“?deviceType =”添加到url中,该值也可以被欺骗。
http://localhost/mypage.html?deviceType=Tablet
Ext.os.命名是单返回:
- 的iOS
- 的Android
- 的webOS
- 黑莓
- RIMTablet
- 的MacOS
- 的Windows
- Linux的
- 巴达
- 其他
浏览器检测的能力,通常可通过Ext.browser.name。
东西我是最近才遇到的,我爱的是特征检测 - 允许编码类似的Modernizr/YepNope设备的基于断能力。 Ext.feature报价:
- Ext.feature.has.Audio
- Ext.feature.has.Canvas
- Ext.feature.has.ClassList
- Ext.feature.has.CreateContextualFragment
- Ext.feature.has.Css3dTransforms
- Ext.feature.has.CssAnimations
- Ext.feature.has.CssTransforms
- Ext.feature.has.CssTransitions
- Ext.feature.has.DeviceMotion
- Ext.feature.has.Geolocation
- Ext.feature.has.History
- Ext.feature.has.Orientation
- Ext.feature.has.OrientationChange
- Ext.feature.has.Range
- Ext.feature.has.SqlDatabase
- Ext.feature.has.Svg
- Ext.feature.has.Touch
- Ext.feature.has.Video
- Ext.feature.has.Vml
- Ext.feature.has.WebSockets
为了检测全屏/应用在iOS /主屏幕的浏览模式:
window.navigator.standalone == true
方向Ext.device.Orientation和方向的变化:
Ext.device.Orientation.on({
scope: this,
orientationchange: function(e) {
console.log('Alpha: ', e.alpha);
console.log('Beta: ', e.beta);
console.log('Gamma: ', e.gamma);
}
});
方向是基于视口。我通常添加一个更可靠的监听器:
onOrientationChange: function(viewport, orientation, width, height) {
// test trigger and values
console.log('o:' + orientation + ' w:' + width + ' h:' + height);
if (width > height) {
orientation = 'landscape';
} else {
orientation = 'portrait';
}
// add handlers here...
}
我确实看到过这种方式,但问题在于我还想指定设备是移动设备还是平板电脑。 Android例如可以在平板电脑或移动设备上运行。 –