Search code examples
javascript.netwinformswebbrowser-controlinvokescript

Returning an Array of strings or custom javascript objects via InvokeScript in a WebBrowser control


I'm trying to get an array of strings or an object back from a web page which has a function named GetAddressToPaste. So far, I've not had much look. I know the script is working as I can get a given string back but nothing more complex than that.

Anybody have experience with this, I'm trying to prototype some work to decide whether to go with a scraping approach rather than a functional JS API.

Thanks in advance.

try
{
    string html = webBrowser1.Document.Body.InnerHtml;
    var v = webBrowser1.Document.InvokeScript("GetAddressToPaste");
}
catch (Exception ex)
{
    return;
}

Solution

  • Issue seemed to be with the JS I was calling, worked fine in FF