how to make winforms webbrowser control to work ve

2020-04-10 03:44发布

问题:

we are targeting our winforms webbrowser control to IE8 with registry key of 8000.

Below are the issues , frequently we face

  1. Script errors which are not seen on IE are visible using webbrowser control.
  2. web page rendering issues on webbrowser control, works fine on IE
  3. Few dropdownlists doesn't work on webbrowser control

回答1:

  1. Try this code to set the FEATURE_BROWSER_EMULATION.
  2. If you have access to the web pages you're loading into WebBrowser, use X-UA-Compatible:

    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=8" />
        ...
    </head>
    

    You can also try IE=EmulateIE8, the difference is explained here.

  3. Once the above has been done, verify the actual document mode:

    webBrowser.DocumentCompleted += (s, e) => MessageBox.Show(
        ((dynamic)webBrowser.Document.DomDocument).documentMode.ToString());