Source View equivalent for <mx: HTML> Component

After setting the management location to any site. How could I then peek into related HTML? I notice that as soon as I set Location, the htmlText will become null and vice versa ... So, how would you look at the HTML displayed in the control in the form of TEXT?

+6
flex actionscript-3 air
source share
2 answers

They are sure that this cannot be done, but the trick is to use the DOM.

My HTML control is called 'html'

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

The DOM is contained within the HTML component of 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 am not a JavaScript expert, but you basically have a DOM for you through html.htmlLoader.window. Besides being not a very convenient way to view the source, it allows you to perform many JavaScript-esque tasks using ActionScript.

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

+5
source share

I always forget how to do it, and I really just looked for how to do it again. Found this snippet in an old project:

 HTMLComponent.domWindow.document.documentElement.outerHTML 

Although I'm not sure if this represents modifications made by javascript.

be sure to trace this only in the full event from the HTML component (unless you know that the page has finished loading).

+3
source share

All Articles