[英]Detecting “Tablet/Touch Mode” in Edge using JavaScript on Windows 10?
This question was asked before, but the answers are not exactly what I need. 之前曾问过这个问题,但答案并非我真正需要的。
I need to distinguish in Microsoft Edge if it's a tablet or not (Desktop). 如果不是平板电脑,我就需要在Microsoft Edge中加以区分(台式机)。
1) The following thread: Can you detect "Tablet Mode" in Edge and IE11 using JavaScript on Windows 10? 1)以下线程:是否可以在Windows 10上使用JavaScript在Edge和IE11中检测“平板电脑模式”?
worked indeed, but I'm afraid that in the next version Microsoft will change the behavior. 确实可以正常工作,但是恐怕Microsoft在下一版本中会更改行为。
How can I be sure that they won't? 我如何确定他们不会?
Answers with if condition of window.PointerEvent
do not work at all, since it's defined in Desktop. 回答
if condition of window.PointerEvent
根本不起作用,因为它是在桌面中定义的。
I can't use CSS Media Queries Interaction media features as suggested here: Is there any way to detect if user has launched microsoft edge tablet or desktop browser? 我不能使用此处建议的CSS Media Queries Interaction媒体功能: 是否有任何方法可以检测用户是否已启动Microsoft Edge平板电脑或桌面浏览器?
Here are the hardware specific differences in the Edge browser capabilities: 以下是Edge浏览器功能中特定于硬件的区别:
The only differences are due to certain device-specific qualities – for example, codec support may be different on phones due to missing hardware acceleration, and Flash is not supported on Windows 10 Mobile.
唯一的区别是由于某些特定于设备的质量–例如,由于缺少硬件加速,电话上的编解码器支持可能有所不同,而Windows 10移动版不支持Flash。 Because Windows 10 Mobile has a different background model, RTC (Real-Time Communications) APIs are also currently not supported.
由于Windows 10移动版具有不同的背景模型,因此当前也不支持RTC(实时通信)API。 Finally, Windows 10 Mobile does not support Flash in order to provide a modern, touch-focused, and power-efficient experience appropriate for a mobile device.
最后,Windows 10移动版不支持Flash,以提供适用于移动设备的现代,注重触摸且节能的体验。 Because of this, Flash is not supported in Microsoft Edge in Continuum.
因此,Continuum中的Microsoft Edge不支持Flash。
To detect RTC capabilities, use the following code: 要检测RTC功能,请使用以下代码:
if (RTCRtpCapabilities)
{
initRTC();
}
function initRTC()
{
var recvAudioCaps = RTCRtpReceiver.getCapabilities("audio");
var recvVideoCaps = RTCRtpReceiver.getCapabilities("video");
var sendAudioCaps = RTCRtpSender.getCapabilities("audio");
var sendVideoCaps = RTCRtpSender.getCapabilities("video");
}
Embedding a Flash movie which uses an ExternalInterface call would be the easiest way to detect Flash. 嵌入使用ExternalInterface调用的Flash电影是检测Flash的最简单方法。
The properties of the navigator
object should be able to distinguish tablet from phone. navigator
对象的属性应该能够区分平板电脑和手机。 For example: 例如:
navigator.cpuClass
should return x86
for Surface devices, but other
for phones. 应该返回
x86
地表设备,但other
的手机。
Also, the user agent changes when casting a phone display to a TV. 同样,当将电话显示器投射到电视上时,用户代理也会更改。 It goes from:
它来自:
Microsoft Edge UA (Mobile) Microsoft Edge UA(移动版)
Mozilla/5.0 (Windows Phone 10.0; Android 6.0.1; Microsoft; <Device>) AppleWebKit/<Rev (KHTML, like Gecko) Chrome/<Rev> Mobile Safari/<Rev> Edge/<Rev>
to: 至:
Microsoft Edge UA (Continuum) Microsoft Edge UA(连续体)
Mozilla/5.0 (Windows NT 10.0; ARM) AppleWebKit/<Rev> (KHTML, like Gecko) Chrome/<Rev> Safari/<Rev> Edge/<Rev>
compared to the desktop: 与台式机相比:
Microsoft Edge UA (Desktop) Microsoft Edge UA(台式机)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/<Rev> (KHTML, like Gecko) Chrome/<Rev> Safari/<Rev> Edge/<Rev>
References 参考文献
Microsoft Edge and Continuum: Your desktop browser on Mobile Microsoft Edge和Continuum:您在Mobile上的桌面浏览器
Microsoft Edge Dev Guide: Object RTC API Microsoft Edge开发指南:对象RTC API
ORTC Specification: dictionary RTCRtpCapabilities ORTC规范:字典RTCRtpCapabilities
Flash Player guidance for Internet Explorer 11 and Microsoft Edge Internet Explorer 11和Microsoft Edge的Flash Player指南
Security Error when trying to call ActionScript function from JS 尝试从JS调用ActionScript函数时出现安全错误
how to tell if android user came from home screen app 如何分辨android用户是否来自主屏幕应用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.