codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  document.fileSize  Archive Import (Nick) at 22:56 on Sunday, July 20, 2003
 

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
%>
*****

  Re: document.fileSize  Archive Import (The wilting pansy.) at 08:38 on Friday, August 22, 2003
 

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.


  Re: document.fileSize  Archive Import (Nick) at 00:31 on Saturday, August 23, 2003
 

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.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  How do I use PHP with Solr?
•  Need to enter XML content into HTML formatted email document
•  Lightweight components reuses its parents graphical units. Heavyweight components
•  lightweight and heavyweight component
•  array of struct
•  matrix prblm in java
•  Re: how to open instantly a pop up window whenever a user sends a message to the other user
•  Re: PING PROGRAM IN PERL
•  Re: date of birth validation using java script-very urgent


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010