Changing the stylesheet of a nested page at runtime

First off, I apologize if this doesn't make sense. I'm new to XHTML, CSS and JavaScript.

I gather that in XHTML, the correct way to have a nested page is as follows (instead of an iframe):

<object name="nestedPage" data="http://abc.com/page.html" type="text/html" 
width="500" height="400" />

If I have a nested page like that - is it possible to change the stylesheet used by the nested page at runtime using JavaScript in the parent page? Ideally this would happen immediately so that the nested page would never be visible with its original stylesheet.

Please assume that you do not have control of the original source code of the nested page, yet it is on the same domain (don't ask)

Answers


d = document.getElementsByTagName('object').namedItem('nestedPage').getContentDocument();
d.styleSheets[d.styleSheets.length].href = 'whereever';

WARNING: hasn't been tested in all browsers.


Need Your Help

Django Inclusion Tag doesn't post to database

python django inclusion

I'm trying to build a form to save Names and Email Adresses to my database. However, it doesn't save...