views:

68

answers:

2

Are there any properties or events I can listen for from within the iframe to determine this?

The iframe src and parent page are on different domains.

A: 

I know you don't have control over the parent page, but if you can convince the host to add some code, you may be able to do something like the following:

//OnParent Page
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script>
    var bReady = false;
    $(document).ready(function () {
        bReady = true;
    });

    function isReady() {
        return bReady;
    }
</script>

//in iframe page
<script>
    var bReady = false;
    while (bReady == false) {
        bReady = window.opener.isReady();
    }
</script>
Brandon Boone
+3  A: 

Only if you can modify the parent page as well. If you can't, it's XSS and there's no legitimate way to do it.

parent.html:

...
<body onload="theFrame.parentLoaded()">
...
<iframe src="http://other.domain.com/frame.html" name="theFrame"></iframe>
...

frame.html:*

...
<script type="text/javascript" language="javascript">
function parentLoaded(){
    //code here will be executed when the parent page has finished loading
}
</script>
...
qmega
I can tell you first hand that I have called javascript on a parent page from inside an iframe. Ever look at the source of a page with an iframe on it? The iframe's entire content is loaded inside the parent page. The iframe only acts as a sandbox to keep the two pages from colliding with each other (separating their html, css, and javascript). But, they're still loaded into the same browser window, which leaves some loop holes we can exploit. Like calling "window.opener.a_parentFunction() or top.frames[name].a_function()" both referencing the parent.
Brandon Boone
Neither of those worked for me, but I did find something that works and updated my answer.
qmega