...

View Full Version : Get URL Size in bytes



deathswan
12-30-2003, 08:43 PM
I am a total newb so please dont leave anything out if you can help me. Heres the deal: at www.gameranger.com/indicator.cgi?account#here the size of the webpage will tell whether or not the user is online or offline(2,247 bytes if ONLINE, and 1,051 bytes if OFFLINE) I am building a webpage which will tell if members in my "clan" are online or offline on the Gameranger service. I need to embed a javascript into my html that will compare the size of the above url with the clan members account number to the above byte sizes. Depending on which one it matches, I need to display the word "online" or "offline" next to that person's name on my webpage. Please help me, and leave your AIM screenname if you can so I can communicate that way. Thanks!

brothercake
12-30-2003, 09:37 PM
You can't read a filesize in Javascript. You could do it serverside, in PHP or ASP.

fredmv
12-30-2003, 09:38 PM
http://forums.webdeveloper.com/showthread.php?s=&threadid=24337 :rolleyes:

Willy Duitt
12-30-2003, 09:49 PM
You can't read a file size?
Doesn't this work?
It does for me.


<script type="text/javascript">
function getSize(){
size=Number(document.fileSize);
for(i=0;i<document.images.length;i++)
size+=Number(document.images[i].fileSize);
for(j=0;j<document.embeds.length;j++)
size+=Number(document.embeds[j].fileSize);
alert('Total document size: '+size+' bytes');
}
</script>
</HEAD>

<BODY onload="getSize()">
<img src="http://www.bobmcleod.com/titans.gif">

.....Willy

brothercake
12-30-2003, 09:49 PM
I stand corrected :o

But only just ;)

Willy Duitt
12-30-2003, 10:19 PM
Picked that up at a Bookmarklet site somewhere.
Since Bookmarklets are uncommented.
I'm unsure whom to credit.

.....Willy

fredmv
12-30-2003, 11:12 PM
That example appears to only work in IE; in other browsers it returns the special Number.NaN value.

Willy Duitt
12-30-2003, 11:50 PM
Ooops;

I just checked it with Netscape6.2 and got NaN bytes.

.....Willy

deathswan
12-31-2003, 12:19 AM
Guys it is giving me the size of my html file as opposed to the size of the "indicator" located at www.gameranger.com/indicator.cgi?127066


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function getSize(){
size=Number(document.fileSize);
for(i=0;i<document.images.length;i++)
size+=Number(document.images[i].fileSize);
for(j=0;j<document.embeds.length;j++)
size+=Number(document.embeds[j].fileSize);
alert('Total document size: '+size+' bytes');
}
</script>
</HEAD>

<BODY onload="getSize()">
<img src="http://www.gameranger.com/indicator.cgi?127066">
</body>

</html>

brothercake
12-31-2003, 02:29 AM
Well yeah - that method calculcates the size of the current document, not a remote URL. To get the size of a remote URL you'll have to use the method in fredmv's link.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum