views:

428

answers:

2

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

A: 

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)
Alconja
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="http://a.com/jquery.js"></script> etc ?
Tom
Alconja
oh ok great thanks!
Tom
A: 

some situations IE7 takes different domains/Virtual Folders from href address... www.foo.com and foo.com are different domains etc. Do you have a linkage like that?

Megawolt
hey thanks - i think my prob might be related to x-domain. i think setting the document.domain javascript is only for subdomains ?
Tom
you can't use document.domain = "foolis.foo.com". Did talk about that?
Megawolt
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 ?
Tom
http://webreflection.blogspot.com/2008/06/ajax-or-javascript-subdomain-requestes.htmlThere is a code for using document.domain for sub and alternative domains. Have a look there...
Megawolt