Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of "View Source" for <mx:HTML> Component

After setting an control's location to some site. How could I then take a peek at the associated HTML? I notice that as soon as I set Location, htmlText becomes null and vice-versa... So how would one go about looking at the HTML displayed in the control in TEXT form?

like image 920
Joshua Avatar asked Aug 04 '10 10:08

Joshua


2 Answers

They sure don't make this easy, but the trick is to use the DOM.

My HTML control is named 'html'

<mx:HTML id="html" location="http://www.googolflex.com" 
       width="100%" height="100%" />

The DOM is contained within in the HTML component's HTMLLoader, which is conveniently called 'htmlLoader'.

var o : Object = html.htmlLoader.window.document.getElementsByTagName("html")[0];
trace( o.textContent );
trace( o.innerText );
trace( o.innerHTML );

I'm not a JavaScript expert, but you essentially have the DOM exposed to you through html.htmlLoader.window. Aside from being a not-so-convenient way to view the source, this allows you to do a lot of JavaScript-esque tasks via ActionScript.

This help document lead me to this solution: Accessing DOM and JavaScript objects from ActionScript

like image 109
jdusbabek Avatar answered Oct 20 '22 01:10

jdusbabek


I always forget how to do this, and i've actually just been searching how to do it again. Found this snippet in an old project of mine:

HTMLComponent.domWindow.document.documentElement.outerHTML

Though i am not sure if this represents modifications made by javascript.

be sure to only trace this on a complete event from the HTML component (unless you know the page has finished loading).

like image 3
bigtallbill Avatar answered Oct 20 '22 00:10

bigtallbill