English 中文(简体)
如何在另一页的iFrame内动态改变超文本页的风格?
原标题:How to dynamically change the stylesheet of an HTML page within an iFrame of another page?

我有一个网页,利用了“团结倡议”的主题。 在该页内,有iFrame持有另一个超文本文件,也利用了“团结倡议”的主题。 现在,我自己选择了主题,我很想知道,它如何影响iFrame的网页。 例如,每当用户选择一个新主题时,我简单地做的是:

<link id="uiTheme" rel="stylesheet" type="text/css" href="ui/smoothness.css" />
$("#uiTheme").attr("href", "ui/" + newTheme + ".css");

? 现在,我如何能够改变在框架内使用的表格,使之与主页相匹配? 我怀疑我的问题是,我如何利用 j子的挑选器来 gr住与<代码>innerTheme的id链接,以改变其hr子的特性。 此外,我是否甚至需要对此表示担忧,或者外部网页的顶峰不会自动地渗入框架中,而没有连接风格的页码?

如果我的问题有点混淆,我道歉。 如果需要,我可以尝试澄清任何事情。

最佳回答

你不必提及他们的联系要素——只是补充你们自己的内容,而且会凌驾于不顾。

var link = document.createElement( link );
link.href = "http://full.domain.com/ui/smoothness.css";
link.type =  text/css ;
link.rel =  stylesheet ;
$( head , frameName )[0].appendChild(link);

然而,如果你来自另一个领域,那么你就能够改变其他框架的任何内容。 因此,如果从同一领域得到服务,那么就更容易在原页上作改动。 如果它来自另一个地点,可悲的是,你从uck子中转走。

问题回答

Here is some code which i hope can help a little: It loops through the iframe stylesheets toggling them on/off

javascript: var i=0;
for(var j=0;j < window.frames.length;j++){
  cs=!window.frames[j].document.styleSheets[0].disabled;
  for(i=0;i<window.frames[j].document.styleSheets.length;i++) 
    window.frames[j].document.styleSheets[i].disabled=cs;
};
void(cs=true);

该守则的依据是:





相关问题
Subclass check, is operator or enum check

A couple of friends was discussing the use of inheritance and how to check if a subclass is of a specific type and we decided to post it here on Stack. The debate was about if you should implement a ...

C++ Class Inheritance problem

Hi I have two classes, one called Instruction, one called LDI which inherits from instruction class. class Instruction{ protected: string name; int value; public: Instruction(string ...

Overloading a method in a subclass in C++

Suppose I have some code like this: class Base { public: virtual int Foo(int) = 0; }; class Derived : public Base { public: int Foo(int); virtual double Foo(double) = 0; }; ...

Embedding instead of inheritance in Go

What is your opinion of this design decision? What advantages does it have and what disadvantages? Links: Embedding description

Extending Flex FileReference class to contain another property

I want to extend the FileReference class of Flex to contain a custom property. I want to do this because AS3 doesn t let me pass arguments to functions through event listeners, which makes me feel sad,...

Interface Inheritance in C++

I have the following class structure: class InterfaceA { virtual void methodA =0; } class ClassA : public InterfaceA { void methodA(); } class InterfaceB : public InterfaceA { virtual ...

热门标签