There is an iframe, opened in fancybox window.
The content of the iframe is external.
Is there a way to access this content and to change the style of one of the elements?
Asked
Active
Viewed 6,251 times
3

lvil
- 4,326
- 9
- 48
- 76
-
external iframe means another domain? – Govind Malviya Oct 02 '11 at 12:35
-
AFAIK , it is not possible because of cross domain access security – Govind Malviya Oct 02 '11 at 12:48
-
1http://stackoverflow.com/questions/1378433/cross-domain-url-access-from-iframe-using-javascript – Govind Malviya Oct 02 '11 at 12:51
2 Answers
10
Since the iframe has contents from the same domain, access the iframe using contents()
like this:
$('#fancybox-content iframe').contents().find('.selector')

Mottie
- 84,355
- 30
- 126
- 241
-
3In my case it was $('.fancybox-iframe').contents().find('selector'); but still, thank you! – meridius Mar 19 '13 at 13:22
3
If the iFrame is on another domain you can't access it in any way due to browser restriction. This is called same origin policy.
One thing that can get around it is the greasmonkey extension for firefox (this has no actual utility, it's just to let you know this fact if you are interested)

Nicola Peluchetti
- 76,206
- 31
- 145
- 192