tags:

views:

39

answers:

3

I wonder if there's some way to specify that a page in a frame is to use the style sheet of the parent? Or to specify a style sheet for the frame? Some option on the frameset or frame tag?

A: 

If the frames are PHP pages you could place them in the frame like

<frame src="page.php?style=cool">

Then in the frame source have

<?php echo '<link rel="stylesheet" href="' . $_GET['style'] . '">'; ?>

It is unlikely than an option for <frame> exists since each frame is it's own page, context, etc.

Andrew67
No joy then as I don't have a server.
Mike D
+1  A: 

There is no such option. But you could inject link element into the frame after it loads and if it loads from the same domain.

Alex Reitbort
A: 

I dont think there is any way by which you can direct a frame to use css used in the parent. Most people use frames to acheive css isolation.

you can write a simple script to copy all external css references from the parent to the frame

var links = window.parent.document.getElementsByTagName('link');
for( var i=0;i<links.length;i++)
    if(links[i].getAttribute('rel').toLowerCase() == 'stylesheet')
       document.appendChild(links[i]);   
Vinay B R