c# - Webbrowser control behaving different than IE - Stack Overflow

in my application I use the WebBrowser-Control to display a local HTML-file. The file includes jQuery a

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
Add a ment  | 

2 Answers 2

Reset to default 3

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745452209a4628323.html

相关推荐

  • c# - Webbrowser control behaving different than IE - Stack Overflow

    in my application I use the WebBrowser-Control to display a local HTML-file. The file includes jQuery a

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信