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

Community
  • 1
  • 1
Tom
  • 39
  • 1
  • 1
  • 3
  • 1
    You already asked this question: 2953158. Asking again won't get you a different answer. You cannot do this, you cannot work around it. If you can, it's a bug and the IE team will fix it. – i_am_jorf Jun 02 '10 at 05:10
  • Are you manipulating the DOM before page is fully loaded? IE gets all fussy about that... – Piskvor left the building Jun 02 '10 at 05:10
  • the question relates to possible workarounds which I still dont have any adequate answer too? writing "you cannot do this" - is not an answer. do i need to defer the script or ? – Tom Jun 02 '10 at 05:12
  • That's why I said it in a comment, not an answer. Go modify your original question; this is still a dupe. – i_am_jorf Jun 02 '10 at 05:19
  • hi - i guess this is the problem with SO. i asked a question 8 hours ago and get no answers and still no help, the views haven't changed. i ask it now and i get help. delete the original - it offers no help to the community - this does. – Tom Jun 02 '10 at 05:34
  • @Tom - if you had've edited your original it would've been bumped up the front page again & got more views. – Alconja Jun 02 '10 at 05:53
  • oh apologies - didnt realize that. thanks for explaining that to me - will ensure i do this next time. – Tom Jun 02 '10 at 06:11

2 Answers2

1

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
  • 14,834
  • 3
  • 60
  • 61
  • 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 etc ? – Tom Jun 02 '10 at 05:20
  • @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 `` tag on them. – Alconja Jun 02 '10 at 05:52
  • 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): http://benalman.com/projects/jquery-postmessage-plugin/ – rinogo Jun 28 '13 at 17:23
0

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
  • 589
  • 5
  • 19
  • hey thanks - i think my prob might be related to x-domain. i think setting the document.domain javascript is only for subdomains ? – Tom Jun 02 '10 at 05:21
  • you can't use document.domain = "foolis.foo.com". Did talk about that? – Megawolt Jun 02 '10 at 05:29
  • 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 Jun 02 '10 at 05:31
  • http://webreflection.blogspot.com/2008/06/ajax-or-javascript-subdomain-requestes.html There is a code for using document.domain for sub and alternative domains. Have a look there... – Megawolt Jun 02 '10 at 05:39