Open In App

HTML DOM ProgressEvent

The ProgressEvent interface represents events measuring the progress of an underlying process, like an HTTP request or the loading of the underlying resource of an img, audio, video, or link. 

Syntax:



ProgressEvent.lengthComputable|loaded|total

Return Value: It returns a string value that represents the lengthComputable, loaded, or total measurement of progress. 

Properties: Properties of ProgressEvent are inherited from its parent event.



Event Types:

Example: In this example, we will use the DOM ProgressEvent




<!DOCTYPE html>
<html>
 
<head>
    <title>DOM ProgressEvent</title>
</head>
 
<body>
    <h1 style="color:green;">
          GeeksforGeeks
      </h1>
    Progress Bar:
    <progress id="geeks"
              style="width:400px;">
    </progress>
 
    <script>
        let progressBar = document.getElementById("geeks"),
            client = new XMLHttpRequest();
        client.open("GET", "magical-unicorns");
        client.onprogress = function (pe) {
            if (pe.lengthComputable) {
                progressBar.max = pe.total;
                progressBar.value = pe.loaded;
            }
        }
        client.onloadend = function (pe) {
            progressBar.value = pe.loaded;
        }
        client.send();
    </script>
 
</body>
 
</html>

Output:

  

Supported Browsers: The browser supported by DOM ProgressEvent are listed below:


Article Tags :