?
Solved

No document.fileSize in one page

Posted on 2003-03-10
6
Medium Priority
?
219 Views
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');
</SCRIPT>

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 ,
Claudio
0
Comment
Question by:cladiniz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8105181
<jAy>

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.

</jAy>
0
 

Expert Comment

by:jeronimus
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

0
 

Author Comment

by:cladiniz
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

0
Technology Partners: 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

by:jeronimus
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;
}  

...
0
 
LVL 16

Expert Comment

by:jaysolomon
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.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0
 

Accepted Solution

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

modulo
Community Support Moderator
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
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

752 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