"Access is denied" iFrame IE

15,865

Put simply, browser security won't let you communicate between two frames that are on different domains. So you can't "grab the jQuery library" from another frame. There's no work around or it would be a security hole in the browser.

Your only options are to do one of the following:

  • Not communicate between the frames (eg. load jQuery in all frames that need it)
  • Host the content of each frame on the same domain (you can work with different subdomains)
Share:
15,865
Tom
Author by

Tom

Updated on June 04, 2022

Comments

  • Tom
    Tom almost 2 years

    Possible Duplicate:
    Permission Denied IE iFrame

    I have an iframe in b.com which attempts to grab the jQuery library from a.com [my website]. Whenever it does this I get the "Access is Denied" error in both IE7 and IE8.

    I have checked out Fiddler and it doesnt show that the script is getting blocked - but IE does errors with "Access is Denied"

    What is causing this prob and how to get around it ?

    Thx

  • Tom
    Tom almost 14 years
    hey thanks for the reply. so option 1 - "load jQuery in all frames that need it" - how do I do this ? i.e. i am loading it using script tags directly from my domain with a P3P. i.e. in the iframe on b.com its <script src="a.com/jquery.js"></script> etc ?
  • Tom
    Tom almost 14 years
    hey thanks - i think my prob might be related to x-domain. i think setting the document.domain javascript is only for subdomains ?
  • Megawolt
    Megawolt almost 14 years
    you can't use document.domain = "foolis.foo.com". Did talk about that?
  • Tom
    Tom almost 14 years
    my site is www.a.com the iframe is on www.b.com ? i.e. document.domain only helps [i think] if www.a.com and bla.a.com ? or ?
  • Megawolt
    Megawolt almost 14 years
    webreflection.blogspot.com/2008/06/… There is a code for using document.domain for sub and alternative domains. Have a look there...
  • Alconja
    Alconja almost 14 years
    @Tom - If you want both the main page & the iframe to have access to jQuery, you just need to include the script tag in both... i.e. the page hosted on a.com & the page hosted on b.com both need a <script ...jQuery.js...></script> tag on them.
  • TommyAutoMagically
    TommyAutoMagically almost 11 years
    This answer makes it sound like it is impossible to communicate between frames that are on different domains, which is inaccurate. One solution, for example, would be the window.postMessage method. For more info (for jQuery users): benalman.com/projects/jquery-postmessage-plugin