Welcome Guest Search | Active Topics | Sign In | Register

WebBrowser - page source Options
Arturas
Posted: Tuesday, January 14, 2014 6:06:24 AM
Rank: Newbie
Groups: Member

Joined: 1/14/2014
Posts: 6
Hello,

how can I access plain source of final HTML page (after all scripts have run and all DOM modifications made)?

I have problems with document.getElementsByClassName('xxx') - because classes/content is created dynamically - so it may be acceptable for me to work in plain HTML - but how to access it? :)

Thank you
eo_support
Posted: Tuesday, January 14, 2014 9:46:47 AM
Rank: Administration
Groups: Administration

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

You can do:

Code: C#
string html = (string)webView1.EvalScript("document.documentElement.outerHTML");


That should return you the full source code of the HTML page in its current state.

Thanks!
Arturas
Posted: Tuesday, January 14, 2014 5:47:17 PM
Rank: Newbie
Groups: Member

Joined: 1/14/2014
Posts: 6
Hello,


thank you for the quick reply!

However "document.documentElement.outerHTML" does not display latest modifications to HTML document. I.e. in web browser I see images that are not available in outerHTML, for example.
So the question is "how do I get the contents of exactly what I see now"?... :)

This may not be a problem with standard documents, however I have a situation with highly dynamic content, where standard HTML is content-empty page used only to load Javascripts - and they run their own app and recreate contents as it is needed.

Thank you
eo_support
Posted: Tuesday, January 14, 2014 5:56:32 PM
Rank: Administration
Groups: Administration

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

I am not sure why you don't think document.documentElement.outerHTML is the current HTML. That JavaScript returns exactly what the current contents is. In fact this doesn't even have much to do with us ---- this is standard JavaScript code to get the current page HTML. You can use the same code with Chrome browsers to get the current page HTML in your JavaScript code. The key thing that is different with our product is we pass the value from the JavaScript world to your .NET world so that it's available to your .NET code.

Thanks!
Arturas
Posted: Wednesday, January 15, 2014 2:42:24 AM
Rank: Newbie
Groups: Member

Joined: 1/14/2014
Posts: 6
Hello,


the web page I see in WebBrowser (pictures & etc.) is quite different from the code "document.documentElement.outerHTML" function returns. This is from real app. I can put screenshots, I can send you source-code, or you can just believe my word :)

The function "document.documentElement.outerHTML" works correctly by itself - when I run it in Firebug, I get the same result - visual content is different from HTML code.

Thank you,
eo_support
Posted: Wednesday, January 15, 2014 8:48:13 AM
Rank: Administration
Groups: Administration

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

That's the standard way to get page HTML. So if you still believe they are different, you may want to debug your page to find out exactly what is different or what can trigger the difference. Obviously we are not in a position to debug an issue if it also exists in Firebug.

Thanks!
Arturas
Posted: Wednesday, January 15, 2014 10:21:59 AM
Rank: Newbie
Groups: Member

Joined: 1/14/2014
Posts: 6
Hello,


it's not my objective and intention to perform web site debugging :) I am asking for a feature to access latest actual document DOM tree/source in your component :) obviously you have it, because you are displaying it :)


Thank you :)
eo_support
Posted: Wednesday, January 15, 2014 12:01:12 PM
Rank: Administration
Groups: Administration

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

We have already told you more than once "document.documentElement.outerHTML" is the correct answer. You have the option to disagree with us but we do not have a different answer for you. So please consider this issue is closed. The fact that you are getting the same result from a different browser already made it very clear that the value returned by our product is correct. That's why we suggested you to look into your web page to find out what's wrong yourself. We will not investigate or respond this issue further.

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.