Web浏览器控件中的拼写检查无法在IE11仿真下运行 [英] Spellcheck in web browser control not working under IE11 emulation
问题描述
我正在尝试在Winforms网络浏览器控件中进行拼写检查。
这是我当前的C#代码:
尝试
{
String appname = Process.GetCurrentProcess()。ProcessName +" .exe" ;;
RegistryKey key = Registry.LocalMachine.OpenSubKey(" Software \\Microsoft \\\\Internet Explorer \\ Major \\ FeatureControl \\FEATURE_BROWSER_EMULATION",RegistryKeyPermissionCheck.ReadWriteSubTree);
object ieVal = key.GetValue(appname,null);
MessageBox.Show(ieVal.ToString());
if(ieVal == null ||(int)ieVal!= 11001)
{
key.SetValue(appname,11001,RegistryValueKind.DWord);
}
key.Close();
}
catch
{
MessageBox.Show("注册表内容不起作用");
}
MessageBox.Show(webBrowser1.Version.ToString());
webBrowser1.DocumentText ="< html>< head>< body>< div spellcheck = \" true \"风格= \"宽度:100%;高度:100%; \" CONTENTEDITABLE = \" true\">< / DIV>"
+"< script> alert(navigator.userAgent);< / script>"
+"< / body>< / html>" ;;
所以首先我设置正确的注册表项,以便浏览器模拟IE11。
然后我添加一个div标签,其中spellcheck属性设置为true。
以下MessageBox中显示的版本为: 11.0 。 9600.18525
MessageBox.Show(webBrowser1.Version.ToString ())
Javascript显示的 navigator.userAgent
是: Mozilla / 5.0
( Windows NT
6.1 ; WOW64 ;
三叉戟 / 7.0 ; rv : 11.0 )
喜欢 Gecko
所以看起来Web浏览器控件正在使用IE11。但是当我键入拼写检查时不起作用。
注意:当我使用真实IE运行该html代码时,一切正常。
此外,实际浏览器上显示的 navigator.userAgent
是:
Mozilla / 5.0
( Windows NT
6.1 ; WOW64 ;
三叉戟 / 7.0 SLCC2 ;
。 NET CLR 2.0 。 50727 ;
。 NET CLR 3.5 。 30729 ;
。 NET CLR 3.0 。 30729 ;
媒体 中心 PC
6.0 ;
。 NET4 。 0C ;
。 NET4 。 0E ; rv : 11.0 )
喜欢 Gecko
注2:当我在Windows 10计算机上运行应用程序时,拼写检查有效。但是我需要让它在Windows 7机器上运行。
请检查注册表,检查修改是否成功。
>>当我运行时在拼写检查工作的Windows 10机器上的应用程序。但我需要在Windows 7计算机上运行。
您还需要在Windows 7计算机上升级IE版本。
如果一切正常,请尝试另一种方法来更改WebBrowser渲染模式,
你可以添加
指定旧文档模式以控制文档模式。< meta http-equiv ="X-UA-Compatible"content ="IE = 11">
希望这可以对你很有帮助。
最好的问候,
Bob
<跨度>
I am trying to have spellcheck work in a Winforms web browser control.
This is my current C# code:
try { String appname = Process.GetCurrentProcess().ProcessName + ".exe"; RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", RegistryKeyPermissionCheck.ReadWriteSubTree); object ieVal = key.GetValue(appname, null); MessageBox.Show(ieVal.ToString()); if (ieVal == null || (int)ieVal != 11001) { key.SetValue(appname, 11001, RegistryValueKind.DWord); } key.Close(); } catch { MessageBox.Show("Registry stuff didn't work"); } MessageBox.Show(webBrowser1.Version.ToString()); webBrowser1.DocumentText = "<html><head><body><div spellcheck=\"true\" style=\"width:100%; height:100%;\" contenteditable=\"true\"></div>" +"<script>alert(navigator.userAgent);</script>" +"</body></html>";
So first I set the proper registry key so that the browser emulates IE11.
Then I add a div tag with spellcheck attribute set to true.
The version shown in the following MessageBox is: 11.0.9600.18525
MessageBox.Show(webBrowser1.Version.ToString())
The navigator.userAgent
that the Javascript displays is: Mozilla/5.0
(Windows NT
6.1; WOW64;
Trident/7.0; rv:11.0)
like Gecko
So it seems like the web browser control is using IE11. But when I type the spell check doesn't work.
Note: When I run that html code with the real IE everything works properly.
Also, the navigator.userAgent
displayed on the actual browser is:
Mozilla/5.0
(Windows NT
6.1; WOW64;
Trident/7.0; SLCC2;
.NET CLR 2.0.50727;
.NET CLR 3.5.30729;
.NET CLR 3.0.30729;
Media Center PC
6.0;
.NET4.0C;
.NET4.0E; rv:11.0)
like Gecko
Note2: When I run my application on a Windows 10 machine the spellcheck works. But I need to make it work on Windows 7 machines.
Hi,
Please check the registry, check whether the modified successfully.
>>When I run my application on a Windows 10 machine the spellcheck works. But I need to make it work on Windows 7 machines.
You also need to upgrade IE version on your Windows 7 machines.
If all is ok, try another approach to change the WebBrowser render Mode,
you can add Specifying legacy document modes to control the document mode.
<meta http-equiv="X-UA-Compatible" content="IE=11">Hope this can be helpful to you.
Best Regards,
Bob
这篇关于Web浏览器控件中的拼写检查无法在IE11仿真下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!