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.