Welcome Guest Search | Active Topics | Sign In | Register

EO.WebBrowser using GetDOMWindow the element body is null Options
Cristiano Conte
Posted: Tuesday, October 7, 2014 12:28:32 PM
Rank: Member
Groups: Member

Joined: 9/25/2014
Posts: 19
Hi,

I need parse the html but, the value "body" is null. What is the problem ?

Code: C#
public Form1()
{
       string htmlBasic = @"<html><head></head><body>teste</body></html>";

       webView1.LoadHtml(htmlBasic); //OR webView1.LoadUrl("www.nytimes.com");

       webView1.LoadCompleted += new EO.WebBrowser.NavigationTaskEventHandler(webView1_LoadCompleted);
}

void webView1_LoadCompleted(object sender, EO.WebBrowser.NavigationTaskEventArgs e)
{
	EO.WebBrowser.DOM.Window domWindow = webControl1.WebView.GetDOMWindow();

        EO.WebBrowser.DOM.Element body = domWindow.document.body;
}


Thanks.
eo_support
Posted: Tuesday, October 7, 2014 5:28:02 PM
Rank: Administration
Groups: Administration

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

Thanks for posting in the forum. We have confirmed that this is a bug. Please use the following code instead:

Code: C#
//The return value is actually an JSObject object
object bodyObj = webControl1.WebView.EvalScript("document.body");

//Cast the JSObject into an Element
EO.WebBrowser.DOM.Element body = JSObject.CastTo<EO.WebBrowser.DOM.Element>(bodyObj);


You can find more details about EvalScript and JSObject here:

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

Please feel free to let us know if you still have any questions.

Thanks!
Cristiano Conte
Posted: Wednesday, October 8, 2014 10:03:16 AM
Rank: Member
Groups: Member

Joined: 9/25/2014
Posts: 19
Hi,

Thanks for the reply. Great with following code worked.

Thanks!

eo_support wrote:
Hi,

Thanks for posting in the forum. We have confirmed that this is a bug. Please use the following code instead:

Code: C#
//The return value is actually an JSObject object
object bodyObj = webControl1.WebView.EvalScript("document.body");

//Cast the JSObject into an Element
EO.WebBrowser.DOM.Element body = JSObject.CastTo<EO.WebBrowser.DOM.Element>(bodyObj);


You can find more details about EvalScript and JSObject here:

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

Please feel free to let us know if you still have any questions.

Thanks!
eo_support
Posted: Wednesday, October 8, 2014 1:26:06 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
You are very welcome. Thanks for confirming that it works for you!


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.