简体   繁体   中英

Webbrowser control behaving different than IE

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 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. I've also tried calling the function by navigating to a javascript: -URL which didn't work as well.

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. 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.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:

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM