Jump to content

HTML5 Progress Bar. Fake?!


iPixel

Recommended Posts

So i was looking around for an HTML 5 progress bar, figured i'd get some good use out of it and couldn't hurt to learn how.

So after some googling here and there, the following script is really the one i found to be mostly used.

 

<progress id="bar" value="0" max="100">
    <span id="fallback"><!-- Your fallback goes here --></span>
</progress>

<script language="javascript">
window.onload = function() {
            
    var bar = document.getElementById("bar"), 
    fallback = document.getElementById("fallback"), 
    loaded = 0;
    
    var load = function() {
        loaded += 10;
        bar.value = loaded;
        
        /* The below will be visible if the progress tag is not supported */
        $(fallback).empty().append("HTML5 progress tag not supported: " + loaded + "% loaded");
        
        if(loaded == 100) {
            clearInterval(dummyLoad);
        }
    };
    
    var dummyLoad = setInterval(function() {
        load();
    } ,1000);        
}
</script>

 

Here's my issue, unless i'm being javascript retarded... this "progress bar" is a fake. It doesnt actually load based on page content load it simply gets triggered onLoad and continues to do so at the setInterval untill it reaches 100 even if the page loaded in 1 second.

 

So i guess my question is... is there an HTML 5 progress bar that truly represents the page loading or are we stuck with this fake just for the "look of it"?

 

Thanks for the help!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.