开发者

css and js repeat download problem

Hi: IN my application,I have to use the IFrame.

For example,the Default.aspx:

.....
<body>
  <iframe src="01.aspx" .../>
  <iframe src="02.aspx" .../>
  <iframe src="03.aspx" .../>
  .........
</body>

The o1/02/03.aspx use some same css and js,for example:

01.aspx's head:

<script src="main.js" ... />

In 02.aspx'head:

<script src="main.js" ... />

When I run the Default.aspx,I found the main.js is downloaded three times according the firebug,I wonder why?

UPDATE:

Default.aspx:

<html>
    <head><title>default page</title></head>
    <body>
        <iframe src="common/01.aspx" scroll="auto" />
        <iframe src="common/02.aspx" scroll="auto" />
        <iframe src="common/03.aspx" scroll="auto" />
    </body>
</html>

01.aspx:

<html>
    <head><title></title>
        <script type="javascript" src="js/main.js"/> 
    </head>
    <body>
        <table id="01">
        ......
        </table>
    </body>
</html>

02.aspx:

<html>
    <head><title></title>
        <script type="javascript" src="js/main.js"/> 
    </head>
    <body>
        <table id="02">
        ......
        </table>
    </body>
<开发者_开发问答;/html>

main.css

table{
width:100%;
border-collapse:collapse;
border:1px solid blue;
}
....


It's simple - each iframe must individually load main.js (and the other assets).

Firebug is showing all the HTTP requests from inside all the iframes.


iframes are separate pages, it is like you have 1 page, clik in a link and go to a 2 page and click in a link and go in to a 3 page, if page1, page2 and page 3 use main.js it is loaded 3 times.

if dont want 3 times load dont use iframes

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜