【问题标题】:Webbrowser Control stealing shortcuts网络浏览器控制窃取快捷方式
【发布时间】:2009-03-28 11:16:45
【问题描述】:

我的 .NET Windows 窗体应用程序中的 Web 浏览器控件在获得焦点时会窃取快捷方式。为了能够使用Alt + F4,我必须先单击一个控件。

目前是“WebbrowserShortcuts = false”,但还是一样。

有没有办法阻止这种恼人的行为?

【问题讨论】:

  • WB 中显示的是什么?像 Office 文档或 .pdf 之类的东西?
  • 不,这只是我通过 DocumentText 填写的 HTML

标签: .net winforms webbrowser-control shortcut


【解决方案1】:

我在 winforms WebBrowser 中加载 Silverlight 时遇到了这个问题,我通过在 <body> 元素中添加以下内容解决了这个问题:

onload="document.getElementById('silverlightControl').focus()"

...当然,这意味着我必须为我的 <object> 元素提供一个 silverlightControl 的 ID:

<object id="silverlightControl" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">

如果您只有 HTML,也许您可​​以在 document 或第一个超链接上调用 focus()

【讨论】:

  • 我遇到了这个答案,因为我遇到了同样的问题,并尝试了 onLoad='document.focus();'。那没有用(它只是 WebBrowser 中的纯 HTML,使用了 jQuery,但没有开始)。 WebBrowserShortcutsEnabled = 假。当我将其设置为 true 时,它​​确实允许我退出,但我也不希望启用所有其他快捷方式,所以我不能这样做。
猜你喜欢
  • 2010-12-31
  • 2010-12-02
  • 1970-01-01
  • 2023-03-27
  • 2012-03-26
  • 2021-09-15
  • 1970-01-01
  • 1970-01-01
  • 2023-03-19
相关资源
最近更新 更多