Mike D
Mike D

Reputation: 2841

html frames css

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?

Upvotes: 0

Views: 406

Answers (3)

Vinay B R
Vinay B R

Reputation: 8421

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]);   

Upvotes: 0

Alex Reitbort
Alex Reitbort

Reputation: 13696

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.

Upvotes: 1

Andrew67
Andrew67

Reputation: 357

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.

Upvotes: 0

Related Questions