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 f开发者_StackOverflowrame tag?
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.
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]);
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.
精彩评论