How to add meta tag when loading site by web browser control

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
i got this code

Here is a code snippet used from web browser control's DocumentCompleted event:


Forms.WebBrowser browser = sender as Forms.WebBrowser;
if (browser == null) return;
Forms.HtmlDocument htmlDocument = browser.Document;
if (htmlDocument == null) return;

Forms.HtmlElement ie8MetaElement = htmlDocument.CreateElement("META");
ie8MetaElement.SetAttribute("content", "IE=8");
ie8MetaElement.SetAttribute("http-equiv", "x-ua-compatible");
Forms.HtmlElement headElement = htmlDocument.GetElementsByTagName("HEAD")[0];
headElement.Children[0].InsertAdjacentElement(Forms.HtmlElementInsertionOrientation.BeforeBegin, ie8MetaElement);
it is not working. so tell me how could add meta tag in the page which loading into browser control of winform project

Continue reading...
 
Back
Top