Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Get URL Size in bytes

    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!

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can't read a filesize in Javascript. You could do it serverside, in PHP or ASP.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #3
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can't read a file size?
    Doesn't this work?
    It does for me.

    Code:
    <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

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I stand corrected

    But only just
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #6
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Picked that up at a Bookmarklet site somewhere.
    Since Bookmarklets are uncommented.
    I'm unsure whom to credit.

    .....Willy

  • #7
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That example appears to only work in IE; in other browsers it returns the special Number.NaN value.

  • #8
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ooops;

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

    .....Willy

  • #9
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ughhhhh

    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>

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •