[英]Webbrowser control behaving different than IE
in my application I use the WebBrowser-Control to display a local HTML-file. 在我的应用程序中,我使用WebBrowser-Control来显示本地HTML文件。 The file includes jQuery and a custom js-File.
该文件包括jQuery和自定义js文件。
When I open the file with IE (locally), everything works just fine. 当我使用IE(本地)打开文件时,一切正常。 However, if I display the file with the WebBrowser control in my application, JQuery is not fully working (Some stuff does work, things like
$.(...)addClass('abc')
does not). 但是,如果我在应用程序中使用WebBrowser控件显示文件,则JQuery无法完全正常工作(某些功能确实可以工作,例如
$.(...)addClass('abc')
功能不能工作)。
Anyone have an idea why this might be the case? 有人知道为什么会这样吗? I'm using
Navigate()
to navigate to the HTML-file and then use InvokeScript
on the WebBrowser's document to call a javascript function that is using jQuery. 我正在使用
Navigate()
导航到HTML文件,然后在WebBrowser的文档上使用InvokeScript
来调用使用jQuery的javascript函数。 I've also tried calling the function by navigating to a javascript:
-URL which didn't work as well. 我也尝试通过导航到
javascript:
-URL来调用该函数,但效果不佳。
Thankful for any help 感谢您的帮助
This is a long shot, but I have seen instances where the WebBrowser control defaults to an older version of the IE rendering engine for some reason even though a newer version of IE is installed. 这是一个很长的路要走,但是我看到一些实例,其中由于某些原因,即使安装了新版本的IE,WebBrowser控件仍默认使用旧版本的IE呈现引擎。 Some older versions of IE could have issues with jquery.
某些旧版本的IE可能与jquery有关。
Try adding some js to ensure it's using the version of IE you are expecting. 尝试添加一些js以确保它使用的是您期望的IE版本。
http://obvcode.blogspot.com/2007/11/easiest-way-to-check-ie-version-with.html http://obvcode.blogspot.com/2007/11/easiest-way-to-check-ie-version-with.html
There is a nice articel written by Rick Strahl regarding to this problem and the solution: 关于这个问题和解决方案,Rick Strahl写了一篇很好的文章:
http://www.west-wind.com/weblog/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version http://www.west-wind.com/weblog/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version
You have to set two registry keys, one for 32 bit and one for 64 bit applications. 您必须设置两个注册表项,一个用于32位,一个用于64位应用程序。
32 bit:
32位:
HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION
HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ Internet Explorer \\ MAIN \\ FeatureControl \\ FEATURE_BROWSER_EMULATION
Value Key: yourapplication.exe
值键:yourapplication.exe
64 bit:
64位:
HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION
HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Wow6432Node \\ Microsoft \\ Internet Explorer \\ MAIN \\ FeatureControl \\ FEATURE_BROWSER_EMULATION
Value Key: yourapplication.exe
值键:yourapplication.exe
The value to set this key to is ( taken from MSDN here ) as decimal values: 将此键设置为的值( 从MSDN此处获取 )为十进制值:
9999 (0x270F) Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
9999(0x270F)Internet Explorer9。无论!DOCTYPE指令如何,网页均以IE9标准模式显示。
9000 (0x2328) Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
9000(0x2328)Internet Explorer9。包含基于标准的!DOCTYPE指令的网页以IE9模式显示。
8888 (0x22B8) Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
8888(0x22B8)网页以IE8标准模式显示,无论!DOCTYPE指令如何。
8000 (0x1F40) Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
包含基于标准!DOCTYPE指令的8000(0x1F40)网页以IE8模式显示。
7000 (0x1B58) Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.
包含基于标准的!DOCTYPE指令的7000(0x1B58)网页以IE7标准模式显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.