简体   繁体   English

如何强制浏览器窗口始终位于顶部且处于焦点位置

[英]How do I force a browser window to always be on top and in focus

Is there a way to force a browser window to always be on top and in focus? 有没有办法强制浏览器窗口始终在焦点上? I am working on a project that I need to have the browser window on top and in focus all the time except when closing the browser window. 我正在开发一个项目,除了关闭浏览器窗口之外,我需要将浏览器窗口置于顶部并始终处于焦点。 I have tried a few things through javascript, but have not had any success keeping the window in focus. 我已经通过javascript尝试了一些东西,但没有任何成功保持窗口的焦点。

I am not trying to do this to be forceful to the user. 我并不是想对用户强有力。 I am working on a project to implement online testing and I don't want the user to be able to switch away to look up answers on the web. 我正在开发一个实现在线测试的项目,我不希望用户能够切换到在网上查找答案。

You will need to install a windows application on the clients machine which will force the browser to be on top. 您将需要在客户端计算机上安装Windows应用程序,这将迫使浏览器位于顶部。 This is the only way. 这是唯一的方法。

If you are using IE, you can open a Modal dialog which will always be on top and in focus but only while in that browser session, the user is free to switch applications. 如果您使用的是IE,则可以打开一个模态对话框,该对话框始终位于顶部且处于焦点位置,但只有在该浏览器会话中,用户才能自由切换应用程序。

Edit: If you are writing a testing application, you are honestly better off just putting a reasonable time limit on each question. 编辑:如果您正在编写一个测试应用程序,那么您最好只为每个问题设置一个合理的时间限制。 trying to prevent them from looking up the answers is worthless. 试图阻止他们查找答案毫无价值。 What if they have two machines side by side? 如果他们并排有两台机器怎么办? What if they have their buddy next to them helping with the answers. 如果他们旁边有他们的伙伴帮助解答怎么办? You are going to have to go with the honor system on this one. 你将不得不在这个上使用荣誉系统。

This is not possible, as the application level focus is handled by the Windows operating system. 这是不可能的,因为应用程序级别的焦点由Windows操作系统处理。

You would need to alter the operating system in order to achieve this functionality. 您需要更改操作系统才能实现此功能。

I commented on the question, but realized this is worth posting as an answer... 我评论了这个问题,但意识到这值得张贴作为答案......

Find another solution. 寻找其他方案。 Think a little about it. 想一想。 If a user is off looking at answers in another window/tab/browser, what would be the side-effects of that? 如果用户不在另一个窗口/标签/浏览器中查看答案,那会产生什么副作用? Detect those side-effects, and penalize/block in those cases. 检测那些副作用,并在这些情况下惩罚/阻止。

For instance, you can detect the blur event on the window and then poll for activity ( focus , click , mousemove , keypress and so on) to determine "idle" time for the user. 例如,您可以检测出blur的事件window ,然后轮询活动( focusclickmousemovekeypress等),以确定“空闲”时间的用户。 If the user is "idle" long enough to have gone elsewhere to find an answer, they are more than likely "cheating". 如果用户“闲置”足够长时间去其他地方寻找答案,那么他们很可能“作弊”。 You can otherwise simply impose time constraints on questions, and skip those questions if the time allotted runs out. 否则,您可以简单地对问题施加时间限制,如果分配的时间用完,则跳过这些问题。

You can't guarantee that your user is not "cheating". 您无法保证您的用户不会“作弊”。 Either construct the "physical" rules of the test such that the chance of "cheating" is minimized, or construct the test itself so that "cheating" is less consequential. 要么构建测试的“物理”规则,以便最大限度地减少“作弊”的可能性,要么构建测试本身,以便“作弊”不那么重要。 Do not try to circumvent in-built user protections in browsers that disallow users from operating their browser as they would any other application. 不要试图绕过浏览器中的内置用户保护,这些浏览器禁止用户像操作任何其他应用程序一样操作浏览器。

The browser window belongs to the browser, not to you. 浏览器窗口属于浏览器,而不属于您。 Don't screw around with it. 不要用它拧紧。

Don't do it, that is, unless you wrote the browser. 不要这样做,也就是说,除非你写了浏览器。

It once took me 15 minutes to create a reasonable web browser by using the Windows Forms WebBrowser control. 我曾经花了15分钟来使用Windows Forms WebBrowser控件创建一个合理的Web浏览器。 I suggest you require the students to view your site through this custom browser program. 我建议您要求学生通过此自定义浏览器程序查看您的网站。 Since this program really will be yours, you can force it to stay on top, or anything else you like. 由于这个计划真的是你的,你可以迫使它留在上面,或者其他任何你喜欢的。

JavaScript具有这样的功能,但在大多数现代webbrowsers中默认禁用它(并且,你肯定会同意,这是有充分理由的!)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何强制Facebook登录窗口始终位于顶部? - How can I force a Facebook login window to always be on top? 如何使用浏览器扩展/插件强制关注浏览器窗口? - How to force focus a browser window using browser extension / plugin? 无论浏览器窗口大小如何,如何使图像始终在另一个图像上对齐? - How can I make an image always be aligned on top of another one regardless of browser window size? Javascript始终位于顶部的窗口(无焦点) - Javascript always-on-top window (without focus) 如果2个元素都是可点击的,如何强制浏览器仅处理顶部链接? - How do I force the browser to only handle the top link if 2 elements are clickable? 如何强制颜色框始终以相同的边框大小打开,而与浏览器大小无关? - How do I force a colorbox to always open with the same border size independent of browser size? 如何检查窗口是否有焦点? - How do I check if the window has focus? D3js - 路径卡在浏览器窗口的左上角 - 如何将它们集中? - D3js - Paths stuck in top left of browser window - how do I centralize them? 如何捕获整个浏览器窗口的模糊和焦点? - How can I capture the blur and focus of the entire browser window? 对于移动浏览器,当文本字段成为焦点时,如何将文本字段“推”到页面顶部而不是默认的中间位置? - For mobile browser when a text field is in focus how do I “push” the text field to the top of the page instead of the default middle?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM