By Mircea

2010-06-21 08:35:36 8 Comments

I am trying to access the DOM of an iframe that loads an external URL. Of course that I get a "Permission denied for" error due to cross domain security. How can I make this work? I saw something done with json (but I can not get a json string from my external source) and something done with HTML5 postmessage.

you can see it live at :

The code is:

     $('#get').live('click', function() {

        var currentIFrame = $('#frameDemo');

        alert ("done")

<iframe src="" width="80%" height="600" id='frameDemo'></iframe>
<button id="get">Get</button>

What would the the easiest way to make this work. Thank you


@jAndy 2010-06-21 08:39:48

There is no way to make this work. Unless, the foreign domain you try to access supports a procedure like C.O.R.S, JSONP or postMessage.

There are a few exceptions (like always):

If you're dealing with a WebApp for instance, you can tell your users that they have to grant access to cross-domain-calls.

In Gecko/Firefox for instance, you can call'UniversalBrowserRead')

which enables the browser to access foreign domains via ajax/iframes. In this scenario, an user has to set


to true under about:config to make this work.

In the Internet Explorers of this world, there is a setting called something like allow cross-domain access deeply hidden in the security tab, which must be set to enable.

Chrome allows cross-domain calls with a commandline argument:

chrome.exe --disable-web-security

@Mircea 2010-06-21 15:38:34

Ok, thanx for the info. I am working on this, it should work.

@jherax 2014-10-27 16:15:02

Here you can find some info related to the cross domain requests: Loading cross domain html page with jQuery AJAX

Related Questions

Sponsored Content

23 Answered Questions

[SOLVED] How can I refresh a page with jQuery?

60 Answered Questions

[SOLVED] How to check whether a checkbox is checked in jQuery?

34 Answered Questions

[SOLVED] Add table row in jQuery

28 Answered Questions

[SOLVED] jQuery scroll to element

  • 2011-07-13 09:49:44
  • DiegoP.
  • 2184451 View
  • 2052 Score
  • 28 Answer
  • Tags:   javascript jquery

40 Answered Questions

[SOLVED] Is there an "exists" function for jQuery?

  • 2008-08-27 19:49:41
  • Jake McGraw
  • 703646 View
  • 2535 Score
  • 40 Answer
  • Tags:   javascript jquery

17 Answered Questions

[SOLVED] Disable/enable an input with jQuery?

40 Answered Questions

[SOLVED] Setting "checked" for a checkbox with jQuery?

53 Answered Questions

[SOLVED] How do I check if an element is hidden in jQuery?

15 Answered Questions

[SOLVED] "Thinking in AngularJS" if I have a jQuery background?

14 Answered Questions

[SOLVED] jQuery AJAX cross domain

Sponsored Content