Jump to content

Progress bar dependant on page


Thierry

Recommended Posts

I'm trying to make a progress bar that fills up as the page is loading.
I can do this with a bunch of set variables, but then, in total disregard of how long the page might take to load, it will always take the same amount of time.
What I need is that the bar goes from 0% at the start to 100% when the page has completed loading, whether that takes 1 second or 30 seconds.
So that would mean that if the page will take longer to load (say a heavy search query) the progress bar will fill up more slowly accordingly (like with your browser).
Is there any PHP (or javascript) function/value that can help me with this?

Currently I can only make it last for the same amount of time using a loop and then a flush.
Link to comment
https://forums.phpfreaks.com/topic/17974-progress-bar-dependant-on-page/
Share on other sites

you could fork your script or do what everyone else does and just have an animated gif without any % loading.  The user is really only interested in teh fact that the browser isn't hanging so the gif still working away will satisfy them enough.
Thats probably true, but I still want to be able to do this.
Basicly all I need is some kind of value which I can use to modify the amount of time for the bar to fill up.
(basicly some kind of indication of how long it might take to load the current page).
To do a progress bar you have to know one of two things:  the total time the script will take to execute before it executes, so you can then take the time elapsed and compare it to the time needed and give a percentage...or you need a way to measure the progress of the script, so if the script has finished 20% of itself, then you let the user know that.
Any ideas on how I can figure out how long any given script is going to take? If I for instance do a search on something that yields a lot of results, then naturally the bar should fill up slower.
Any javascript or PHP value or function that can calculate the total time of the execution?
[quote author=Thierry link=topic=104788.msg420816#msg420816 date=1156351287]
The browser loading bar does seem dependant on page loading time so there must be something.
[/quote]

That's because it knows how much data is in/on the page...it's a part of the packet information.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.