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

T

thisis

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?
 
A

Anthony Jones

thisis said:
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.
 
T

thisis

Anthony said:
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.
 
A

Anthony Jones

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?
 
T

thisis

Anthony said:
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 ?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top