I have a document, with an iframe to another page. I cannot directly edit the content of the iframe, but I'd like to use Javascript on the parent page, to insert a stylesheet into the iframe page.

I'm using the following code to add the stylesheet to the parent page, but I'm having no luck getting it to apply to the framed page.

Code JavaScript:
<script type="text/javascript">
var addSS = document.createElement('link');
addSS.rel = 'stylesheet';
addSS.href = 'http://domain.com/style.css';
addSS.type = 'text/css';
document.getElementsByTagName("head")[0].appendChild(addSS);
</script>

I've tried making the last line:

frames['iframename'].document.getElementsByTagName("head")[0].appendChild(addSS);

And

self.iframename.document.getElementsByTagName("head")[0].appendChild(addSS);


Anyone have any suggestions?