|
Rank: Newbie Groups: Member
Joined: 11/8/2016 Posts: 3
|
Hello. I load the page that contains frames. I can not understand how can I get the frame code because getHTML() does not fit. I will be grateful for the help.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, I am not sure what you meant by "getHtml() does not fit". You can always use JavaScript code to get whatever you need and then use WebView.EvalScript to run your JavaScript code and return the value to your .NET code. See here for more details: https://www.essentialobjects.com/doc/webbrowser/advanced/js.aspxThanks
|
|
Rank: Newbie Groups: Member
Joined: 11/8/2016 Posts: 3
|
Example:
Code: HTML/ASPX
<html>
<body>
...
<iframe src="http://www.site.com...">
...
</body>
</html>
After loading frame:
Code: HTML/ASPX
<html>
<body>
...
<iframe src="http://www.site.com...">
<html>
...
</html>
...
</body>
</html>
But, result of GetHTML():
Code: HTML/ASPX
<html>
<body>
...
<iframe src="http://www.site.com...">
...
</body>
</html>
I need to get frame code. Separate loading frame does not fit me.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, You will need to use JavaScript to do that. This page should give some sample code: http://stackoverflow.com/questions/16755347/getting-contents-of-iframe-with-pure-javascriptThe above code will fail if the main page and the iframe page are from different domains. In that case you must set this property to false: https://www.essentialobjects.com/doc/eo.webengine.browseroptions.enablewebsecurity.aspxSee here for more information on how to set browser options: https://www.essentialobjects.com/doc/webbrowser/advanced/browser_options.aspxThanks!
|
|
Rank: Newbie Groups: Member
Joined: 11/8/2016 Posts: 3
|
I set browser options for the main page and the iframe page are from different domains:
Code: C#
EO.WebEngine.BrowserOptions options = new EO.WebEngine.BrowserOptions();
options.EnableWebSecurity = false;
webView.SetOptions(options);
I understood that. JavaScript to another iframe I can use. Example:
Code: C#
webView.EvalScript(@"
frames[2].document.getElementsByClassName('checkbox-checkmark')[0].click();
");
If I could do something like:
Code: C#
webView.GetDOMWindow.frames[2].getHTML();
as to use JavaScript:
Code: JavaScript
frames[2].document.innerHTML
it would be very good
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
We have no plan to support this because EvalScript is much more efficient since it only involves one round trip from the .NET world to the JavaScript world, where as the other option needs a round trip on every property/method call.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 11/8/2016 Posts: 3
|
iframe likely to relate to the structure of the html document than to JavaScript.
|
|
Rank: Newbie Groups: Member
Joined: 11/8/2016 Posts: 3
|
Although you are right, it is better to do so:
Code: C#
string frameCode = (string)webView.EvalScript("frames[2].document.innerHTML");
thanks
|
|