简体   繁体   中英

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 iframe s.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM