2 Replies Latest reply on Apr 24, 2009 10:24 AM by Joe ... Ward

    Accessing an iframe's content via javascript

      I have been having a lot of trouble figuring out how I can access the content within an iframe in Air. Here is some example jquery code that I have been testing with.

       

      $(document).ready(function(){
           $("#frame").ready(function(){
                air.trace($("#frame").contents().find("body").html());
                air.trace(window.frames["frame"].innerHTML);
                air.trace(document.getElementById("frame").innerHTML);
           });
      });
      

       

      The iframe I am using is.

       

      <iframe src="http://google.com" id="frame" width="100%" sandboxRoot="http://google.com/" documentRoot="/" name="frame" height="600"></iframe>
      

       

      The output from the above code is

       

      null
      undefined
      
      

       

      As you can see the contents are always either null, undefined or an empty string. Am I missing something that is preventing me from accessing the content of the iframe? Any suggestions would be greatly appreciated.