Reputation: 238747
I have an iframe loading a page, and I would like to manipulate the contents.
For example:
<iframe id="myIframe" src="http://www.google.com"></iframe>
<script>
$(document).ready(function(){
$(iframeContents).css('background-color', '#000');
});
</script>
How can I do this?
Upvotes: 2
Views: 1421
Reputation: 2028
As Pekka said, you can't, not directly. The JavaScript security model prohibits this. However, you can do it if the domain in the iFrame is the same as the one in which the script runs. So what can be done is to set up a proxy on your own domain, and show the content in the iFrame through the proxy and then use JS to interact with it.
Upvotes: 1