• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6232
  • Last Modified:

Making pages loaded in an iframe inherit parent pages style?

Howdy, my website has 1 parent page with 2 iframes (1 menu, 1 content) that everything is loaded in,

what I want to do is find some way to set the style sheet in the parent page only, and have the iframes 'inherit' and use that style sheet, rather than setting them each individually.

reason being is that I want to create many different versions of the parent page that each use a different style sheet which would be inherited by the iframed content to create a website that can have many different versions.  

cheers

p.s. sorry I only have 130 points available!
0
__rdr__
Asked:
__rdr__
1 Solution
 
webwomanCommented:
Not gonna happen. A separate document is loaded in the iframe, it doesn't 'inherit' anything from the parent container.

If you're looking to create various looks, an iframe isn't a good way to do it. Server side includes would be much easier, and would do what you want.
0
 
der_jthCommented:
If you're iframing your own pages, you're better off by finding some other way for styling those. Styling IFrame content from the container document doesn't work. If you really need to do something like that, take a look at the following discussion thread, which provides tools for adding a new style sheet for the embedded document. It uses JavaScript so it won't be foolproof, but it might help you a bit.

http://webfx.eae.net/webboard/?action=display&id=601&group=data/dhtml
0
 
COBOLdinosaurCommented:
Just put an id on the link in the main page:

<link id="one" rel="stylesheet" type="text/css" href="CSSstyle.css">


Then in the head of the pages coming into the iframe:

<script type="text/javascript">
str=top.document.getElementById('one').href;
document.write('<link id="one" rel="stylesheet" type="text/css" href="'+str+'">');
</script>

Then the page in teh iframe will use whatever stylesheet the parent is using.

Cd&

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
COBOLdinosaurCommented:
Glad we could help. Thanks for the A. :^)

Cd&
0
 
jboyfinnCommented:
Hey, careful now. COBOLdinosur's answer is correct but if the domain strings denoting where the menu page and the content are hosted differ from then JavaScript won't be able sniff out the stylesheet used. Attempting to do so will cause an error (unless IE's security zone preference's stipulate otherwise - for most people they won't).

COBOLdinosaur would be first to back me up on this. See his posting (Accepted Answer) on:
http://www.experts-exchange.com/Web/Web_Languages/CSS/Q_20854526.html

Personally I agree with Webwoman, use a SSI. Is there any reason why you cannot?
0
 
COBOLdinosaurCommented:
1. Where is there any indication of anything being cross-domain?

2. If they are cross-domain, then that implies a server they do not control and therefore could not implement SSI.

3.  Any cross-domain issue for a structure like this would require server side resolution. There is no user setting that would bypass the "access denied" error.

Cd&
0
 
__rdr__Author Commented:
No there is nothing cross domain, I am testing everything fully now and it seems to work just fine.

I have changed the layout to use a frameset rather than an iframe, and was just wondering what
everyone seems to have against iframes?  Are they not widely supported?

Also, does anyone know of any good resource sites for finding out what css elements work with what browsers?



0
 
COBOLdinosaurCommented:
Actually I like iframes correctly used, but I have very little use for frames, because framed sites are a horror to maintain.  

As for a CSS site: http://www.blooberry.com/indexdot/css/index.html

Cd&
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now