How to get the percentage amout of a file being loaded ?

Discussion in 'ASP General' started by thisis, Nov 3, 2006.

  1. thisis

    thisis Guest

    Hi All,

    i'm trying to display the amout in percentage for the loading sub event
    value,
    for the <img .../>


    example:

    the browser should display something like this:

    view 1, time 00:00:05
    loading 5%
    ====================
    view 2, time 00:00:010
    loading 10%
    ====================
    view 3, time 00:00:57
    loading 99%
    ====================
    view 4, time 00:01:00
    complete 100%
    <!-- the image is showen -->

    ====================
    i have this code:

    <script language="vbscript">
    Function showState_onready()
    IF myImgID.readyState = "loading" then
    myDivID.innerText = myImgID.readyState & " " & strPerventage
    Else
    myDivID.innerText = myImgID.readyState & " " & "100%"
    End If
    End Function
    </script>

    <html>
    <head></head>
    <body>
    <div id="myDivID"></div>
    <img id="myImgID" src="img.jpg"
    onreadystatechange="vbscript:showState_onready('')" />
    </body>
    </html>

    i'm trying to display the image amount of the file loaded in
    percentage,
    how do i do it?
    thisis, Nov 3, 2006
    #1
    1. Advertising

  2. "thisis" <> wrote in message
    news:...
    > Hi All,
    >
    > i'm trying to display the amout in percentage for the loading sub event
    > value,
    > for the <img .../>
    >
    >
    > example:
    >
    > the browser should display something like this:
    >
    > view 1, time 00:00:05
    > loading 5%
    > ====================
    > view 2, time 00:00:010
    > loading 10%
    > ====================
    > view 3, time 00:00:57
    > loading 99%
    > ====================
    > view 4, time 00:01:00
    > complete 100%
    > <!-- the image is showen -->
    >
    > ====================
    > i have this code:
    >
    > <script language="vbscript">
    > Function showState_onready()
    > IF myImgID.readyState = "loading" then
    > myDivID.innerText = myImgID.readyState & " " & strPerventage
    > Else
    > myDivID.innerText = myImgID.readyState & " " & "100%"
    > End If
    > End Function
    > </script>
    >
    > <html>
    > <head></head>
    > <body>
    > <div id="myDivID"></div>
    > <img id="myImgID" src="img.jpg"
    > onreadystatechange="vbscript:showState_onready('')" />
    > </body>
    > </html>
    >
    > i'm trying to display the image amount of the file loaded in
    > percentage,
    > how do i do it?
    >


    IE doesn't expose info on the current progress of an image download. All
    you get is a few changes in state when the download starts to received data
    and when the data had complete arrived. You get nothing in between.

    The best you can do is guestimate the time involved in the download and use
    a window.interval to call an update progress function. In this function
    test the readyState of the image if still loading update your progress info
    based on time elapsed otherwise set progress to 100% and kill the interval
    handle.
    Anthony Jones, Nov 3, 2006
    #2
    1. Advertising

  3. thisis

    thisis Guest

    Anthony Jones wrote:
    > "thisis" <> wrote in message
    > news:...
    > > Hi All,
    > >
    > > i'm trying to display the amout in percentage for the loading sub event
    > > value,
    > > for the <img .../>
    > >
    > >
    > > example:
    > >
    > > the browser should display something like this:
    > >
    > > view 1, time 00:00:05
    > > loading 5%
    > > ====================
    > > view 2, time 00:00:010
    > > loading 10%
    > > ====================
    > > view 3, time 00:00:57
    > > loading 99%
    > > ====================
    > > view 4, time 00:01:00
    > > complete 100%
    > > <!-- the image is showen -->
    > >
    > > ====================
    > > i have this code:
    > >
    > > <script language="vbscript">
    > > Function showState_onready()
    > > IF myImgID.readyState = "loading" then
    > > myDivID.innerText = myImgID.readyState & " " & strPerventage
    > > Else
    > > myDivID.innerText = myImgID.readyState & " " & "100%"
    > > End If
    > > End Function
    > > </script>
    > >
    > > <html>
    > > <head></head>
    > > <body>
    > > <div id="myDivID"></div>
    > > <img id="myImgID" src="img.jpg"
    > > onreadystatechange="vbscript:showState_onready('')" />
    > > </body>
    > > </html>
    > >
    > > i'm trying to display the image amount of the file loaded in
    > > percentage,
    > > how do i do it?
    > >

    >
    > IE doesn't expose info on the current progress of an image download. All
    > you get is a few changes in state when the download starts to received data
    > and when the data had complete arrived. You get nothing in between.
    >
    > The best you can do is guestimate the time involved in the download and use
    > a window.interval to call an update progress function. In this function
    > test the readyState of the image if still loading update your progress info
    > based on time elapsed otherwise set progress to 100% and kill the interval
    > handle.


    Hi Anthony Jones,

    i think your "IE doesn't expose info on the current progress of an
    image download."
    is in correct.

    look at this link, see the status bar on the IE, which displays:
    10 items left
    9 items left
    ....
    (the displaying happens real fast)
    http://images.google.co.il/images?hl=en&q=hello&btnG=Search Images

    and i have another example, on my intranet, a page that i worte. i
    didn't write anything special for the behaviour of the status bar i
    desrcibed.

    about your suggestion, i'm trying to think about over.
    thisis, Nov 3, 2006
    #3
  4. > > >
    > >
    > > IE doesn't expose info on the current progress of an image download.

    All
    > > you get is a few changes in state when the download starts to received

    data
    > > and when the data had complete arrived. You get nothing in between.
    > >
    > > The best you can do is guestimate the time involved in the download and

    use
    > > a window.interval to call an update progress function. In this function
    > > test the readyState of the image if still loading update your progress

    info
    > > based on time elapsed otherwise set progress to 100% and kill the

    interval
    > > handle.

    >
    > Hi Anthony Jones,
    >
    > i think your "IE doesn't expose info on the current progress of an
    > image download."
    > is in correct.
    >
    > look at this link, see the status bar on the IE, which displays:
    > 10 items left
    > 9 items left
    > ...
    > (the displaying happens real fast)
    > http://images.google.co.il/images?hl=en&q=hello&btnG=Search Images


    This is updating the as each individual image is complete. You could get
    access to this by attaching an event handler to each img in your page. But
    your post indicates that you are downloading a single large image.

    >
    > and i have another example, on my intranet, a page that i worte. i
    > didn't write anything special for the behaviour of the status bar i
    > desrcibed.


    You're refering to the IEs own internal updating to the status bar. IE has
    access to the internal workings of the Wininet stack and can therefore can
    do things like that as well as show a download progress bar (not that it's
    all that reliable anyway). However that does not mean that IE provides any
    API by which a page developer can get access to these events. It doesn't.

    >
    > about your suggestion, i'm trying to think about over.
    >


    How about letting IE's solution BE the solution?
    Anthony Jones, Nov 3, 2006
    #4
  5. thisis

    thisis Guest

    Anthony Jones wrote:
    > "thisis" <> wrote in message
    > news:...
    > > Hi All,
    > >
    > > i'm trying to display the amout in percentage for the loading sub event
    > > value,
    > > for the <img .../>
    > >
    > >
    > > example:
    > >
    > > the browser should display something like this:
    > >
    > > view 1, time 00:00:05
    > > loading 5%
    > > ====================
    > > view 2, time 00:00:010
    > > loading 10%
    > > ====================
    > > view 3, time 00:00:57
    > > loading 99%
    > > ====================
    > > view 4, time 00:01:00
    > > complete 100%
    > > <!-- the image is showen -->
    > >
    > > ====================
    > > i have this code:
    > >
    > > <script language="vbscript">
    > > Function showState_onready()
    > > IF myImgID.readyState = "loading" then
    > > myDivID.innerText = myImgID.readyState & " " & strPerventage
    > > Else
    > > myDivID.innerText = myImgID.readyState & " " & "100%"
    > > End If
    > > End Function
    > > </script>
    > >
    > > <html>
    > > <head></head>
    > > <body>
    > > <div id="myDivID"></div>
    > > <img id="myImgID" src="img.jpg"
    > > onreadystatechange="vbscript:showState_onready('')" />
    > > </body>
    > > </html>
    > >
    > > i'm trying to display the image amount of the file loaded in
    > > percentage,
    > > how do i do it?
    > >

    >
    > IE doesn't expose info on the current progress of an image download. All
    > you get is a few changes in state when the download starts to received data
    > and when the data had complete arrived. You get nothing in between.
    >
    > The best you can do is guestimate the time involved in the download and use
    > a window.interval to call an update progress function. In this function
    > test the readyState of the image if still loading update your progress info
    > based on time elapsed otherwise set progress to 100% and kill the interval
    > handle.


    Hi Anthony Jones,


    i'm not clear with this:

    > The best you can do is guestimate the time involved in the download and use
    > a window.interval to call an update progress function. In this function
    > test the readyState of the image if still loading update your progress info
    > based on time elapsed otherwise set progress to 100% and kill the interval
    > handle.


    do you have an example for this: guestimate the time involved, usage of
    window.interval ?
    thisis, Nov 4, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcelo Birnbach [MS]
    Replies:
    0
    Views:
    3,321
    Marcelo Birnbach [MS]
    Jun 28, 2003
  2. Udo Corban
    Replies:
    0
    Views:
    3,839
    Udo Corban
    Jan 23, 2004
  3. David Graham
    Replies:
    2
    Views:
    434
    David Graham
    Nov 6, 2003
  4. senges
    Replies:
    0
    Views:
    303
    senges
    Mar 24, 2007
  5. Conax

    Get correct percentage

    Conax, Jan 6, 2004, in forum: ASP General
    Replies:
    6
    Views:
    140
    Dave Anderson
    Jan 7, 2004
Loading...

Share This Page