Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML in desktop application load a page with an iframe

I have a mx:html component in a AIR Desktop Application that load an external webpage into it...

this webpage has an iframe in it and the iframe load (obviously) another page...

I can't figure out how to get the code of the iframe...

If I try to get the webpage content I only retrive the start page like:

File webpage.html

<html>
<!-- html code-->
<iframe src="http://host/framepage.html">content default</iframe>
<!-- other html code-->
</html>

File framepage.html

<div>test test test</div>

I'd like to get the string <div>test test test</div>

please tell me that there is a way to get the content of iframe (without reloading it)...

EDIT

Looking at the response of Exort, using

var iFrame:* = domWindow.document.getElementById("myIframe");

will return me the iframe, but the content it's not the one I want to... Using my webpage and framepage example above, the iframe content I will get is

content default

instead of

<div>test test test</div>

It's like as the second page is not loaded, but it's actually be loaded and rendered in the browser window (i tried also using a button so I can delay the search for the iframe content.

like image 288
Marcx Avatar asked Nov 13 '22 14:11

Marcx


1 Answers

I don't have much time so this might not be a really deep answer, but the iframe is considered in a window and has a document of its own. You can get it's content with the html DOM with something like this. This is AS3 by the way, event if I'm using '*' as the object types. Using Object type won't work really well here.

var domWindow:* = myHTML.htmlLoader.window; //DOM window object

//if you don't have the id, you can get all iframes with getElementsByTagName("iframe")
var iFrame:* = domWindow.document.getElementById("myIframe");

var iFrameContent:String = iframe.contentDocument.body.innerHTML;
like image 85
Exort Avatar answered Nov 17 '22 01:11

Exort