|
I am working on a large asp/dhtml app. I am having a problem with the MS DHTML property document.fileSize.
Below is some code for a page that has the javascript function on it that works in all recent versions of MSIE. However, for some reason, that I have not determined, if I put the same javascript function on a page in my app (the code of which I can not post), it only works in MSIE 5 and not MSIE 5.5 or MSIE 6. It works in MSIE 6 if I save the html and then view the html in the browser. If I do not catch the error, I get a javascript "Unspecified error."
As you can see, I have added things like response buffering and include files that I use in my app in an effort to find the problem.
I am asking if anyone who reads this forum can tell me under what conditions the javascript DOM/DHTML attribute/property document.fileSize works and does not work.
*****
<%@ Language=VBScript %>
<%
Response.Buffer = True
%>
<html>
<title>file size test</title>
<script type=text/javascript language="JavaScript">
<!-- hide from JavaScript-challenged browsers
function pageLoad(){
var fileSize;
try{
fileSize = document.fileSize * 1;
} catch (e){
fileSize = 0;
}
var y = document.images;
var imglength = 0;
for (i=0;i<y.length;i++)
{
imglength += (y.fileSize)*1;
}
htmlString = ``;
if (fileSize > 0){
htmlString = htmlString + `(` + fileSize + ` bytes) `;
}
if (y.length > 0){
htmlString = htmlString + `(` + y.length + ` images for ` + imglength + ` bytes)`;
}
htmlString = htmlString + `</small>`;
try{
footerbottom.insertAdjacentHTML("afterBegin", htmlString);
} catch (e) {
//do nothing
}
}
// done hiding -->
</script>
</head>
<body onload=`pageLoad();`>
<img src="http://www.timeeclipse.com/TE-logo.jpg">
<div name=footerbottom ID=footerbottom></div>
</body>
</html>
<!--#INCLUDE FILE="/forum/test.html"-->
<%
Response.Flush
%>
*****
|
|
|
Basically comes down to caching.
If you use code like this ASP:
Response.expires= 0
Response.Expires=-1
Response.Expiresabsolute = Now() - 1
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
Then the page will return the error for document.fileSize, as the page is no longer available in cache for IE to workout the filesize.
Unfortunately IE doesn`t work out the size of the page in the dom, neither does it workout the size of the document after client side page content generation. It literally just looks at the file on the HD in the cache and tells you the size of it.
Hope this helps.
|
|
|
Worked like a charm. Thanks.
By the way, my app is very cache averse, so I was doing that cache stuff, but also wrote a cache defeating function in javascript that I use on every page, so I didn`t need the cache commands, which I found didn`t always work.
|
|
|
|
|
|
|
|