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

  • Question

  • 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

    Friday, August 30, 2019 2:04 PM


  • Hi Sudip,

    Document completed event might be getting called for multiple times as per the link. You should check that the actual document loaded completely or not.

    Avik Das

    • Marked as answer by Sudip_inn Saturday, August 31, 2019 5:10 AM
    Friday, August 30, 2019 2:39 PM