Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


No document.fileSize in one page

Posted on 2003-03-10
Medium Priority
Last Modified: 2008-02-01
Hello !

I'm coding a script to get the size of a page ...
It works VERY WELL in any page I try , BUT the page I really need this piece of code to work just refuses to accept the script .

In any page , this script works fine :

<SCRIPT LANGUAGE="Javascript">
var size = document.fileSize;
alert(size+' KB');

But in the page I need , it says that I have an error in the line with the "document.fileSize" ! And I just can't figure out why ...

Thanks in advance ,
Question by:cladiniz
LVL 16

Expert Comment

ID: 8105181

I copy/paste your code and it worked for me. Do you have any more code maybe in the page that you are having trouble with, that we can see.


Expert Comment

ID: 8105656
Same Problem here:
i copy&pasted the script into a BLANK html page, alert worked great.

BUT when using the javascript in a by php generated page(maybe extension?) it gave an error on the fileSize function.
using "if(!document.fileSize){ alert('nope'); }" also made it trigger an error(=no alert).
using "var size = (document.fileSize)*1; " also didn't work...

maybe this helped a little


Author Comment

ID: 8106585
This is a very silly thing ! Look what I've tried :

1 - I thought it could be a conflict between this and another javascript that I have in the page , so I took off all the javascripts from the page , left only this one ... and : doesn't work , the same error !

2 - I thought it could be some header problem ... I took off the all the headers from the beggining and I took off all meta tags ... and nothing ...

3 - I stripped down all flash files , iframes , and everything it was possible , until only left the code I wrote above and : NOTHING ! It was very strange !

So , I finally made up why doesn't work ... My page was built under php , and I had a php function session_start() in the top of the page ... I took off and worked !

The javascript function fileSize() can't be used togheter with the php sessions' functions ...

Anybody know a workaround ? I really need a way to know the page's size ... I know I can do with PHP file_size function , but it will only get the HTML size ... I need dome function , either in PHP or javascript to get the size of all the contents of a page , including images , and , if possible , .swf files and external .js and .css files .

I know I can do some php classes to do the whole work , but I don't have time ... Anybody know a solution ??

Thanks guys .

P.S.: Is this a bug ?? I never heard about it ... And I searched a lot and didn't find nothing

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 8106665
yup, sessions did the job :-|
BTW I noticed that the page properties (right-mouse-click -> properties) also didn't give a File size when using a php generated page(with session).

Maybe a solution to your fileSize problem:
- get the HTML/page fileSize, using PHP function
- get the img. fileSize using a javascript for loop ::

for(i=0; i < document.images.length; i++){
  sizeimg += document.images[i].fileSize;

LVL 16

Expert Comment

ID: 10113560
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next seven days.

EE Cleanup Volunteer

Accepted Solution

modulo earned 0 total points
ID: 10168813
PAQed, with points refunded (125)

Community Support Moderator

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question