2

I was working on a project which requires to download content from a database. The site is generally accessed using mobiles (high end smartphones).

I was wondering if it is possible to add a progress bar during the download of the content using HTML5, so that when this action is going on appears a light box through the entire screen and only the progress bar is shown.

beaver
  • 523
  • 1
  • 9
  • 20
Gajanan Arha
  • 45
  • 2
  • 8

2 Answers2

5

It is possible using the 'new' progress events of the XMLHttpRequest

=> more info: Mozilla site

=> or: this thread

The new XMLHttpRequests(2) however are not available in every (mobile)browser.

And there is a 'new' progress/meter control you could use... But it isn't supported yet by any mobile device. So you will have to use a lib like this jquery plugin for example or write one yourself.

(update: now it is also available for Android)

beaver
  • 523
  • 1
  • 9
  • 20
VDP
  • 6,340
  • 4
  • 31
  • 53
2

You can use w3.css to creat w3-progressbar as:

<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">

<body class="w3-container">

<h2>Dynamic Progress Bar with Labels</h2>
<p>Centered label:</p>

<div class="w3-progress-container">
  <div id="myBar" class="w3-progressbar w3-green" style="width:20%">
    <div id="demo" class="w3-center w3-text-white">20%</div>
  </div>
</div>
<br>

<button class="w3-btn w3-dark-grey" onclick="move()">Click Me</button> 

<script>
function move() {
  var elem = document.getElementById("myBar");   
  var width = 20;
  var id = setInterval(frame, 10);
  function frame() {
    if (width >= 100) {
      clearInterval(id);
    } else {
      width++; 
      elem.style.width = width + '%'; 
      document.getElementById("demo").innerHTML = width * 1  + '%';
    }
  }
}
</script>

</body>
</html>