WebBrowser控件不会自动选择文本双击后,IE 10安装双击、控件、文本、WebBrowser

2023-09-03 17:05:53 作者:我是屌丝,我怕谁\(^o^)/~

注:这是一个关于控制内置的行为,而不是有关创建双击事件

NOTE: This is about the control's built-in behavior, not about creating a double-click event.

我的一个项目中使用Windows.Forms.WebBrowser控制作为一个编辑器和查看器的HTML。它一直工作正常多年,但我突然发现,以前的时候我会双击它会自动选择该被点击的话(这不是我的code,刚好与对照)。

One of my projects uses the Windows.Forms.WebBrowser control as an editor and viewer for HTML. It has been working fine for years but suddenly I noticed that before when I would double-click it would automatically select the word which was clicked (this was not my code, just happened with the control).

突然(不完全确定的时候),在控制双击文本(无论是在编辑模式或视图模式)不执行任何操作。这很难但解决,因为这不是我的code这样做,因为我靠过去这个功能,现在影响我的最终产品。

Suddenly (not exactly sure when), double clicking text in the control (both in edit mode or in view mode) does nothing. It's hard to troubleshoot because it is not my code doing it, however, since I depended on this functionality in the past, it is now impacting my final product.

任何想法会最近改变(在Windows或在.net),这将影响到这(我的应用程序的相同版本工作正常老年人的Win7,但不是在最先进最新的Win7)?另外,我怎么可以得到previous功能回来了?我必须连接了我自己的双击即使在DOM,然后开始分析文本,以手动选择(嗯!)?

Any idea what would have recently changed (in Windows or in .Net) which would affected this (the same version of my app works fine in older Win7 but not in the most up-to-date Win7)? Also, how can I get the previous functionality back? Must I wire up my own double-click even on the DOM and then start parsing the text to manually select it (uh!)?

我已经找遍了对这个问题的答案,但大多是我刚才看到如何把高达DOM事件,没有对最近的变化,这将导致上述问题)。任何帮助将大大AP preciated。

I've looked all over for the answer to this question but mostly I just see how to wire up to DOM events, nothing about recent changes which would cause the problem above). Any help would be greatly appreciated.

我使用VS 2010,VB,Win7的X64,IE 10.0.6,NET 3.5的(不管最近的一次是)当问题发生(编译所以我怀疑它是VS或VB)。

I'm using VS 2010, VB, Win7 x64, IE 10.0.6, .Net 3.5 (whatever the latest one is) when the problem happens (compiled so I doubt it is VS or VB).

当我运行完全相同的code(编译)上的Win7的x86与IE 8(Win7的临平原,安装了零更新)它工作得很好。

When I run the exact same code (compiled) on Win7 x86 with IE 8 (Win7 Pro plain, with zero-updates installed) it works just fine.

在一些进一步的测试,在Win7的x86的全新安装(在这里一切都很好),只要我安装IE 10,并没有别的问题开始出现。所以,我是pretty的确定问题出在IE 10。

After some further testing, on the Win7 x86 fresh install (where everything was fine) as soon as I install IE 10 and NOTHING ELSE the problem starts to happen. So, I'm pretty sure the problem lies with IE 10.

重现步骤:

创建在VS 2010中新的VB.Net项目,目标定位的.Net 3.5 创建一个用户控件< ---这一步是关键 添加一个网页浏览器的用户控件

将此code到用户控件 Create a new VB.Net project in VS 2010, targetting .Net 3.5 Create a usercontrol <--- this step is the key Add a webbrowser to the usercontrol

Add this code to the usercontrol

Public Sub LoadHTML(html As String)
    WebBrowser1.DocumentText = html

    Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
        Application.DoEvents()
    Loop

    WebBrowser1.Document.Body.SetAttribute("contentEditable", "false")
End Sub

C webBrowser控件问题

这是控件添加到表单

Add that control to a form

添加一个按钮,按照以下button.Click事件的形式:

Add a button to the form with the following button.Click event:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    UserControl1.LoadHTML("<html><body>This is a test interesting is it not?</body></html>")
End Sub

运行该项目,然后单击按钮

Run the project and click the button

如果你直接在表格上扔WebBrowser控件,它会正常工作。问题是与用户控件(和它只是一个问题,升级到IE10后)。

If you throw the webbrowser control directly on the form, it will work fine. The problem is with the usercontrol (and it is only a problem after updating to IE10).

我可以使用VS 2010使用.net 3.5和4.0重现该问题。 我可以使用VS 2012使用的.Net 4.5重现该问题。

I can reproduce the problem using VS 2010 using .Net 3.5 and 4.0. I can reproduce the problem using VS 2012 using .Net 4.5.

推荐答案

现在的问题是实际上这是由微软这里。

The problem is actually a bug in IE 10. This was confirmed by Microsoft here.

最可悲的是,他们说,他们将不会在短期内进行修复它(如果有的话),因为它影响的人太少了(尽管它会影响成千上万我公司的客户)。

The saddest part is that they said they would not be fixing it any time soon (if ever) because it affects too few people (though it does affect thousands of my company's customers).