Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to use
HTML
<meta http-equiv="X-UA-Compatible" content="IE=9" >

meta before web page rendered on WebBrowserControl.

I tried
C#
void _browser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
       {
           if (_browser.Document != null)
           {
               if (_browser.Document.GetElementsByTagName("head").Count > 0)
               {
                   HtmlElement headTag = _browser.Document.GetElementsByTagName("head")[0];
                   HtmlElement metaIEDocMode = _browser.Document.CreateElement("meta");
                   metaIEDocMode.SetAttribute("content", "IE-9");
                   metaIEDocMode.SetAttribute("http-equiv", "X-UA-Compatible");
                   headTag.AppendChild(metaIEDocMode);
               }
           }
       }


It doesn't work. What is the correct method for this case.
Posted

1 solution

Here is a CP article that describes what you need to do to change the mode of the WebBrowserControl.
Configuring the emulation mode of an Internet Explorer WebBrowser control[^]

then this tag should work
HTML
<meta http-equiv="X-UA-Compatible" content="IE=9" />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900