Reputation: 12235
I'm inserting an iframe to display another website's content in mine, and I'd like to clean it up first. So I tried to use $('iframe').contents
, but the return is undefined, while $('iframe')
works like a charm. Is there some kind of cross site security here ?
Bonus question : how should I clean the page then ? I just need div#main
, not the rest. I'm using an iframe so I can get the original styling.
Thanks for your time
Upvotes: 0
Views: 1596
Reputation: 39223
It's called Same-Origin Policy. Basically, you can't use javascript to interact with pages from another domain (protocol, domain and port must all match).
Upvotes: 2
Reputation: 16953
Is there some kind of cross site security here?
Yes, the Same Origin Policy.
There aren't many ways around it - I once used PHP to fetch the contents of the target webpage and write them locally, but that was quite a specific thing (and I owned both domains).
Take a look at this question: jQuery cross domain iframe scripting
Upvotes: 4