且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

DEL 和 BACKSPACE 键被 WebBrowser 吃掉

更新时间:2023-12-02 22:18:40

免责声明:我的回答与 Outlook 插件无关,但它可以帮助未来的访问者,他们可能会使用搜索引擎找到此页面(和我一样).它与所描述的问题相关,但在不同的上下文中.

今天是 2017 年,没有一个答案有效(已删除、链接和通过谷歌搜索找到的其他答案).我发现在我的情况下(在网页中嵌入 ActiveX 控件),DEL 和 BACKSPACE 以及其他控制键(HOME、END、箭头键)在我按下 TAB 后开始工作,然后继续工作.

Today is 2017, none of the answers worked (deleted, linked and others found by google search). I discovered that in my situation (embedded ActiveX control in a web page), DEL and BACKSPACE as well as other control keys (HOME, END, arrow keys) start working after I press TAB, and continues to work after that.

我添加了

obj.focus();

在我的Javascript中设置.Url后立即,神奇地解决了这个问题(obj是我用.NET编写的ActiveX浏览器,使用WPF浏览器控件下的引擎盖).

Immediately after setting the .Url in my Javascript, and it magically solved the problem (obj is my ActiveX browser written in .NET, using WPF browser control under the hood).

SendKeys从内部设置焦点 .NET 中的控制和拦截键没有帮助.

SendKeys, setting focus from within the control and intercepting keys in .NET did not help.