离开浏览器并返回时小程序永久失去焦点
我有一个网页,其中一个小程序作为唯一的元素,看起来像这样:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>...</title>
</head>
<body>
<applet style="padding:1px; border:1px solid gray" mayscript="mayscript" codebase="..." name="AppletName" code="..." archive="..." width="600" height="500" alt="Alt Text">
<param name="initial_focus" value="true"/>
Alt Text
</applet>
</body>
</html>
当页面最初加载时,焦点设置在小程序中,我可以通过选项卡浏览并与小程序交互。但是,如果我离开浏览器窗口然后返回它,我将无法再仅使用 Tab 键重新获得小程序的焦点。
按F5重新加载页面修复了页面,使Applet重新获得焦点,但这种解决方案是不可接受的。
我该如何解决这个问题?谢谢。
I have a web page with an applet as the only element that looks something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>...</title>
</head>
<body>
<applet style="padding:1px; border:1px solid gray" mayscript="mayscript" codebase="..." name="AppletName" code="..." archive="..." width="600" height="500" alt="Alt Text">
<param name="initial_focus" value="true"/>
Alt Text
</applet>
</body>
</html>
When the page initially loads, focus is set in the applet and I can tab through and interact with the applet just fine. However, if I leave the browser window and then come back to it, I can no longer regain focus on the applet just using the tab key.
Pressing F5 to reload the page fixes the page so that the Applet regains focus, but this solution is unacceptable.
How do I solve this problem? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
暂定解决方案:
请注意,检测小程序是否需要焦点并在需要时请求焦点的关键部分是(这仅在启用 mayscript 的情况下有效):
其余代码只是在页面加载后将窗口附加到焦点处理上(使用脚本 JQuery.ready 是基于)。
欢迎更好的解决方案。
Tentative solution:
Note that the key part for detecting whether the applet needs focus and requesting it if so is (this only works if mayscript is enabled):
The rest of the code is just attaching the window on focus handling after the page is loaded (using the script JQuery.ready is based off of).
Better solutions welcome.