PDA

View Full Version : Raw/source html webpage


Flash Gordon
10-08-2008, 07:22 AM
AIR can load a webpage using the HTMLLoader class which is a DisplayObject (or the HTML component of Flex). But is there a way to get the raw html source of the webpage that was loaded? I've spent hours now looking for how to get the page source. Any help?

Flash Gordon
10-09-2008, 07:43 AM
well....this gives me an interpreted HTML source...but I want the raw source.

var dom:Object = _htmlLoader.window.document;
var source:String = dom.documentElement.outerHTML;

evride
10-17-2008, 12:17 PM
the only way i kno of is to load the page again using a URLLoader. I kno that isnt near perfect but it works. i like the innerHTML/outerHTML way better

Flash Gordon
10-17-2008, 04:53 PM
what do you mean load the page AGAIN? can you give a code sample?

CyanBlue
10-17-2008, 04:56 PM
My guess is that use HTMLLoader to load and display it on the stage, and use URLLoader with the same URL to get the raw source code??

evride
10-18-2008, 06:25 AM
yup. CB knows what im talkin about.

Flash Gordon
10-18-2008, 09:47 AM
i don't understand. Can i see an example?

thanks guys :)

evride
10-18-2008, 08:40 PM
view_source_btn.addEventListener(MouseEvent.CLICK, viewSource);
function viewSource(evt:MouseEvent){
var url:String = htmlLoader.location;
var urlReq:URLRequest = new URLRequest(url);
var loader:URLLoader = new URLLoader(urlReq);
loader.addEventListener(Event.COMPLETE, loadComplete);
loader.load(urlReq);
}
function loadComplete(evt:Event){
trace(evt.target.data);

}

Flash Gordon
10-18-2008, 10:31 PM
gotcha ;)

So I guess there is no "secret" property of HTMLLoader has has a URLLoader object that I can directly access. I guess that works.

Cheers :)