Cross domain iframe content load detection

Posted by fpb on Stack Overflow See other posts from Stack Overflow or by fpb
Published on 2010-05-02T17:29:45Z Indexed on 2010/05/02 17:37 UTC
Read the original article Hit count: 152

Filed under:
|
|

I have a rather interesting problem. I have a parent page that will create a modal jquery dialog with an iframe contained within the dialog. The iframe will be populated with content from a 3rd party domain. My issue is that I need to create some dialog level javascript that can detect if the content of the iframe loaded successfully and if it hasn't within a 5 second time frame, then to close the dialog and return the user to the parent page.

I have researched numerous solutions and only two are of any true value.

  1. Get the remote site to include a javascript line of document.domain = 'our-domain.com'.
  2. Use a URL Fragment hack, but again I would need the request that the remote site able to modify the URL by appending '#some_value' to the end of the URL and my dialog window would have to poll the URL until it either sees it or times out.

Are these honestly the only options I have to work with? Is there not a simpler way to just detect this?

I have been researching if there's a way to poll for http response errors, but this still remains confined to the same restrictions.

Any help would be immensely appreciated.

Thanks

© Stack Overflow or respective owner

Related posts about cross-domain

Related posts about iframe