Onderstaande progress bar voorbeeldcode start met een druk op de knop.
Is het mogelijk om de bar automatisch te laten opstarten bij het downloaden van een programma (als XYZ.asp of ABC.pdf of ...) ?
Dank voor tips.
Is het mogelijk om de bar automatisch te laten opstarten bij het downloaden van een programma (als XYZ.asp of ABC.pdf of ...) ?
Dank voor tips.
Code:
<!DOCTYPE html>
<html>
<style>
#Progress_Status {
width: 50%;
background-color: #ddd;
}
#myprogressBar {
width: 1%;
height: 35px;
background-color: #4CAF50;
text-align: center;
line-height: 32px;
color: black;
}
</style>
<body>
<h3>Example of Progress Bar Using JavaScript</h3>
<p>Download Status of a File:</p>
<div id="Progress_Status">
<div id="myprogressBar">1%</div>
</div>
<br>
<button onclick="update()">Start Download</button>
<script>
function update() {
var element = document.getElementById("myprogressBar");
var width = 1;
var identity = setInterval(scene, 10);
function scene() {
if (width >= 100) {
clearInterval(identity);
} else {
width++;
element.style.width = width + '%';
element.innerHTML = width * 1 + '%';
}
}
}
</script>
</body>
</html>