English 中文(简体)
IFrame, 如何共享 css 文件
原标题:IFrame, how to share css file

我刚刚加入一个项目, 我们用树脂网织来创建网站。

到目前为止,人们一直在各自努力制定自己的DCP,因此,我现在有20个DCP可以联系在一起和风格。

在根部,每个DCP是IView/IFrame。

目前我们有20个cs文件 很难维持和快速更改 所以我想用 scs 生成一个cs文件 使所有的文件都正常运转

这部分很好用,但我遇到了一个问题, 因为每个IFTRAME 都自制, 每一个都装一个CS文件, 所以我得到20个电话到我的新CS文件。

是否在父视图和 IFrame 之间共享 cs 文件, 或者至少设置它, 以便 cs 文件被下载一次, 而其他 19 则只使用缓存版本?

干杯 干杯

杰森·杰森

问题回答
<script type="text/javascript">
  $(document).ready(function() {
  //pulling all <style></style> css of parent document
  if (parent) {
        var oHead = document.getElementsByTagName("head")[0];
        var arrStyleSheets = parent.document.getElementsByTagName("style");
        for (var i = 0; i < arrStyleSheets.length; i++)
            oHead.appendChild(arrStyleSheets[i].cloneNode(true));
    }
 //pulling all external style css(<link href="css.css">) of parent document
    $("link[rel=stylesheet]",parent.document).each(function(){
        var cssLink = document.createElement("link")
        cssLink.href = "http://"+parent.document.domain+$(this).attr("href");
        cssLink .rel = "stylesheet";
        cssLink .type = "text/css";
        document.body.appendChild(cssLink);
    });   
  });
</script>

它将能够继承外部样式表中定义的 cs 以及父文档标记中定义的 cs。





相关问题
Write-though caching of large data sets in WCF?

We ve got a smart client that talks to a SQL Server database via WCF, displaying the entities in the database, and allowing the user to edit those entities. Some of the WCF calls return a large data ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

how to tell clicking "back" to load cache?

I would like for my site when someone clicks "Back" or "Forward" for the server to tell the browser to load the cache instead of reloading the entire page. I ve tested some headers and done research, ...

java plugin cache and dynamic IP host

I m trying to use Amazon S3 and Amazon Cloudfront CDN to deliver the jar files of my applet application. I m seeing several cache misses of my jars by the java plugin. This is a show-stopper for me, ...

Frequently Used metadata Hashmap

Are there any implementations of a static size hashtable that limits the entries to either the most recently or most frequently used metadata? I would prefer not to keep track of this information ...

PHP - Memcache - HTML Caching

I would like to create a caching system that will bypass some mechanisms in order to improve the performance. I have some examples: 1-) I have a dynamic PHP page that is updated every hour. The page ...

Performance of Sql subqueriesfunctions

I am currently working on a particularly complex use-case. Simplifying below :) First, a client record has a many-to-one relationship with a collection of services, that is, a single client may have ...

热门标签