[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Making pages loaded in an iframe inherit parent pages style?

Posted on 2004-10-04
8
Medium Priority
?
6,161 Views
Last Modified: 2011-10-03
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
Comment
Question by:__rdr__
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 19

Expert Comment

by:webwoman
ID: 12220277
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
 
LVL 6

Expert Comment

by:der_jth
ID: 12220283
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
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 520 total points
ID: 12222088
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
Technology Partners: 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!

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12226140
Glad we could help. Thanks for the A. :^)

Cd&
0
 
LVL 1

Expert Comment

by:jboyfinn
ID: 12226937
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12228454
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
 

Author Comment

by:__rdr__
ID: 12232687
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12232704
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question