Welcome Guest Search | Active Topics | Sign In | Register

help with .net webbrowser 2014 Options
dvdrodriguez
Posted: Wednesday, April 15, 2015 6:06:21 PM
Rank: Newbie
Groups: Member

Joined: 4/15/2015
Posts: 0
I am looking for an example in c# for windows forms of webbrowser but cant find nothing.

Any one can help with an example of how to use Document.getElementsByTagName ?

in vs webbrowser is easy to do which is the equivalent in eo.webbrowser to this:

Code: C#
HtmlElementCollection elems = webBrowser1.Document.GetElementsByTagName("a");

foreach (HtmlElement elem in elems)
        {
...
}

eo_support
Posted: Friday, April 17, 2015 8:14:20 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

The code with EO.WebBrowser is similar:

Code: C#
EO.WebBrowser.DOM.Element[] elems = 
    webControl1.WebView.GetDOMWindow().document.getElementsByTagName("a");

foreach (EO.WebBrowser.DOM.Element elem in elems)
{
    ....
}


However our Element class only exposes a few properties. If you need additional data, you can use the indexer property:

http://www.essentialobjects.com/doc/6/eo.webbrowser.jsobject.item1.aspx

For example, elem.id is actually shortcut for elem["id"].

The reason that we do not expose a lot of properties is because every time you access a property or method, the code needs to switch between .NET and JavaScript and this is a rather expensive operation. As such if you have complex logics related to your DOM objects, you should run the logic on JavaScript side and then:

1. Use EvalScript to trigger the code and pass arguments from .NET side to JavaScript side;
2. Use return value or JavaScript extension to pass value back to .NET side. See here for more information about JavaScript extension:

http://www.essentialobjects.com/doc/6/advanced/jsext.aspx

The key is to reduce such boundary crossing. Too many crossing can cause noticeable performance penalty.

Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.