i got free source progress bar, , wrote script it.
the script here,
var nanobar = new nanobar( options ); var loaded = 0; var number_of_media = $("body img").length; doprogress(); // function progress bar function doprogress() { $("img").load(function() { loaded++; var newwidthpercentage = (loaded / number_of_media) * 100; nanobar.go(newwidthpercentage); document.getelementbyid("showing").innerhtml = newwidthpercentage; }) }; });
this. think,
loaded <-- (which gets + 1 every time image finished loaded) divided number of total body images,, , multiplied 100
so can make percentage number of loading process. put percentage number box of, loading bar's destination point. (which : nanobar.go( here ))
but bar moves werid, everytime click menu, returns different. made box display percentage number ( in red box can see in picture )
i don't understand how kind of random numbers coming out every time.
please advice.
consider....
6/7 = 0.8571428571; 0.8571428571 * 100 = 85.71428571;
so if want 'tidy' these long decimals, need truncate float. http://www.w3schools.com/jsref/jsref_tofixed.asp
var num = 0.8571428571 * 100; var n = num.tofixed(2); n == 85.71
i hope helps.
Comments
Post a Comment