0

Is there any way to access elements loaded inside an iframe?

I'm trying this but doesn't seem to work:

if($('#cboxLoadedContent iframe').contents().find('#customer-login')[0] ){ ... }
eozzy
  • 66,048
  • 104
  • 272
  • 428
  • I'm sure this is a duplicate. I'll look if I find a good original question. – Denys Séguret Feb 02 '13 at 16:23
  • possible duplicate of [jQuery/JavaScript: accessing contents of an iframe](http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe) – Ram Feb 02 '13 at 16:24

2 Answers2

1

If the content of the iframe is provided by another domain, the only way you can see its content from your page is that this content is given with appropriate CORS headers.

This is a protection scheme known as Same Origin Policy.

Note that there is also the solution to let the browser see only one domain, by using a proxy.

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
0

It worked, I hd opened the file locally (file://) whereas the content was loaded with http:// protocol.

eozzy
  • 66,048
  • 104
  • 272
  • 428