admin管理员组文章数量:1429008
in my application I use the WebBrowser-Control to display a local HTML-file. The file includes jQuery and a custom js-File.
When I open the file with IE (locally), everything works just fine. 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).
Anyone have an idea why this might be the case? I'm usingNavigate()
to navigate to the HTML-file and then use InvokeScript
on the WebBrowser's document to call a javascript function that is using jQuery. I've also tried calling the function by navigating to a javascript:
-URL which didn't work as well.
Thankful for any help
in my application I use the WebBrowser-Control to display a local HTML-file. The file includes jQuery and a custom js-File.
When I open the file with IE (locally), everything works just fine. 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).
Anyone have an idea why this might be the case? I'm usingNavigate()
to navigate to the HTML-file and then use InvokeScript
on the WebBrowser's document to call a javascript function that is using jQuery. I've also tried calling the function by navigating to a javascript:
-URL which didn't work as well.
Thankful for any help
Share Improve this question asked Nov 13, 2012 at 15:54 DeX3DeX3 5,5797 gold badges46 silver badges70 bronze badges 2-
Is it necessary that it be called from
InvokeScript
rather than native DOM events? – Snuffleupagus Commented Nov 13, 2012 at 15:57 - yes, I'm required to invoke this from the host application – DeX3 Commented Nov 14, 2012 at 7:43
2 Answers
Reset to default 3This 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. Some older versions of IE could have issues with jquery.
Try adding some js to ensure it's using the version of IE you are expecting.
http://obvcode.blogspot./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:
http://www.west-wind./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 bit:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
Value Key: yourapplication.exe
64 bit:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
Value Key: yourapplication.exe
The value to set this key to is (taken from MSDN here) as decimal values:
9999 (0x270F) Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
9000 (0x2328) Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
8888 (0x22B8) Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
8000 (0x1F40) Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
7000 (0x1B58) Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.
本文标签: cWebbrowser control behaving different than IEStack Overflow
版权声明:本文标题:c# - Webbrowser control behaving different than IE - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745452208a2658939.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论