I have an iframe that looks like this:
<iframe id="feed" width="100%" height="100%" frameborder="0" src="http://foo.com/bar"></iframe>
I want to change styles, remove and add elements to the iframe
I tried using this:
function iframeRef(frameRef) {
return frameRef.contentWindow ? frameRef.contentWindow.document : frameRef.contentDocument
}
var inside = iframeRef(document.getElementById('feed'));
var elem = inside.createElement('p');
elem.style.zIndex = '2';
elem.style.position = 'absolute';
elem.innerHTML = 'TEXT';
inside.body.appendChild(elem);
But it doesn't work, how can I manipulate the DOM from the iframe?