如何从浏览器检测用户是否正在远程桌面会话中运行?
如果用户正在远程桌面会话中运行,是否有方法检查浏览器内部(例如 JavaScript)?
如果用户在远程桌面(即终端服务)内运行浏览器,我想禁用网站上的动画。
如果这是一个本机应用程序,而不是一个网站,我可以使用以下命令执行此检查:
//Native code
isRemoteSession = GetSystemMetrics( SM_REMOTESESSION );
或者
//Managed Code:
isRemoteSession = System.Windows.Forms.SystemInformation.TerminalServerSession;
是否可以在浏览器内完成类似的检查?
注意:出于本次讨论的目的,假设我们讨论的浏览器是 Internet Explorer 8。
Is there a ways to check inside a browser (e.g. javascript) if the user is running inside a Remote Desktop session?
If the user is running their browser inside a Remote Desktop (i.e. Terminal Services), i want to disable animations on the web-site.
If this were a native application, as opposed to a web-site, i could perform this checking using:
//Native code
isRemoteSession = GetSystemMetrics( SM_REMOTESESSION );
or
//Managed Code:
isRemoteSession = System.Windows.Forms.SystemInformation.TerminalServerSession;
Is there a similar check that can be done inside the browser?
Note: Assume for the purposes of this discussion that the browser we're talking about is Internet Explorer 8.
Update One: Perhaps something in How can you get the terminal service client machine name from javascript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我的解决方案是使用 CSS
@media
查询颜色
媒体功能。根据实验,RDP 似乎每种颜色只有 5 位,而不是典型桌面的每种颜色完整的 8 位。当然,这个解决方案并不完美,因为您会从那些没有使用 RDP、但碰巧拥有低颜色深度显示器的人那里得到很多误报。但是:
这是一个在最新版本的 Firefox 和 Chrome 中适用于我的示例。请参阅下面的屏幕截图。
另一种方法是使用 javascript 来检查
screen.colorDepth
变量。My solution is to use CSS
@media
queries for minimum and maximum values of thecolor
media feature. Based on experiment, RDP only seems to have 5 bits per color, rather than the full 8 bits per color of your typical desktop.This solution is, of course, not perfect, because you'll get lots of false positives from people who aren't on RDP, but just happen to have low color-depth displays. However:
Here is an example that works for me in recent version of Firefox and Chrome. See the screenshot below.
Yet another approach along these lines is to use javascript to examine the value of the
screen.colorDepth
variable.您可以使用以下媒体查询:
@media screen and (prefers-reduced-motion: reduce) { 。 。 。 此条件
也适用于非 RDP 会话,但由于您的目的是禁用所有动画,因此这种类型的查询可能正是您正在寻找的。
You can use the following media query:
@media screen and (prefers-reduced-motion: reduce) { . . . }
This condition can also hold for non-RDP sessions, but as your intention is to disable all animations, this type of query is probably exactly what you're looking for.
您可以通过 ActiveX 或 BHO 公开检测代码(例如 将属性分配给窗口对象BHO) 如果您使用 IE。
否则,如果您使用 ActiveX 播放器播放动画,请检查播放器的文档以查看它是否在远程桌面下自动调整帧速率。
您始终可以提供网站的低带宽版本,并指示用户在视频播放效果不满意时选择该网站而不是常规网站。
有关编写终端服务感知图形应用程序的提示,请检查 图形效果考虑,以及一般绩效指南
You can probably expose the detection code via an ActiveX or BHO (e.g. assign a property to the window object in BHO) if you use IE.
Otherwise if you are using an ActiveX player to play animation, check the player's documentation to see if it automatically adjust frame rate under remote desktop.
You can always offer a low bandwidth version of your web site and instruct the user choose the web site instead of the regular web site if the video playback is not satisfactory.
For tips in writing a terminal service-aware graphics app, check graphic effects consideration, and the general performance guidelines
也许您可以读取 SESSIONNAME 环境变量?
对于控制台会话,它应该是 CONSOLE;对于 RDP 会话,它应该是 RDP-TCP,后跟一个数字。
Perhaps you can read the SESSIONNAME environment variable?
For a console session it should be CONSOLE and for an RDP session it should be RDP-TCP followed by a number.
我假设您正在谈论特定的公司终端服务器,而不是任何终端服务器。您无法向 TS 的特定 IP 地址提供动画。
I'm assuming you are talking about a specific company terminal server, not any terminal server. You could not serve animations to the specific IP address of the TS.
这不应该由您的应用程序完成或决定。在 RDP 客户端(如 MS RDC)上,用户可以选择禁用动画等。用户也可以在服务器端(终端服务器或 RDP 主机)禁用这些
This should not be done or decided by your application. On RDP client (like MS RDC), user can choose to disable animations etc. User can also disable these on server side (Terminal server or RDP host)