Sep 042010

Have an iFrame inside a document and you need to access the iframe data and make decisions based on that data…
Few problems

  1. Same Origin Policy
  2. Frame Load incomplete.

No. 1 is easy, if the two Top Level Domain aren’t the same, you cannot read the iframe data. Even for the same domain and different subdomains, one needs to write the following on the top of both client and the server:

 document.domain = "" 

No. 2

How to determine that the iframe has loaded completely in order to scan data off it ?


will surely tell you if the page has loaded, but it won’t wait for the iframe(s) inside the parent document to finish loading, before returning true.

One may think, this might work:

$(document).ready(function() {

     $('#myIframe').ready(function() {
                // ALL CODE GOES HERE

BUT, it doesn’t. The above code will tell you ONLY that the iframe loading has started, but won’t
tell you if its done.

Well, the OLD window.onload to the rescue:

window.onload = function () {
    $('#myIframe').ready(function() {
                // ALL CODE GOES HERE

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>