none
How to add new button to wbpage after finish loading RRS feed

  • Question

  • Hello,

     iam using webbrowser control to open external page

    i would like to add new button to  that  page after finish loading

    this the code for the button

    how to add it ?

    <button type="button" class="res-actions__item bui-button bui-button--secondary bui-button--wide" ><!----> <span class="bui-button__text"><span>Submit</span></span></button>


    Tuesday, November 12, 2019 11:27 AM

Answers

  • Hello,

    See the following documentation and code sample. The real challenge is to have an event for the button, the following is a model that can get you started but there can be issues like doing this multiple times can get tricky.

    Dim head As HtmlElement = WebBrowser1.Document.GetElementsByTagName("head")(0)
    Dim script As HtmlElement = WebBrowser1.Document.CreateElement("script")
    Dim element As IHTMLScriptElement = CType(script.DomElement, IHTMLScriptElement)
    element.text = "function sayHello() { alert('hello') }"
    head.AppendChild(script)
    webBrowser1.Document.InvokeScript("sayHello")
    


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, November 12, 2019 11:45 AM
    Moderator

All replies

  • Hello,

    See the following documentation and code sample. The real challenge is to have an event for the button, the following is a model that can get you started but there can be issues like doing this multiple times can get tricky.

    Dim head As HtmlElement = WebBrowser1.Document.GetElementsByTagName("head")(0)
    Dim script As HtmlElement = WebBrowser1.Document.CreateElement("script")
    Dim element As IHTMLScriptElement = CType(script.DomElement, IHTMLScriptElement)
    element.text = "function sayHello() { alert('hello') }"
    head.AppendChild(script)
    webBrowser1.Document.InvokeScript("sayHello")
    


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, November 12, 2019 11:45 AM
    Moderator
  • Thank you so much.
    Tuesday, November 12, 2019 12:37 PM