Core JavaScript

Reading a Blob

This program demonstrates how to read a blob.

ReadABlob.html

<!DOCTYPE html>
<html>
<head>
	<title>XoaX.net's Javascript</title>
	<script type="text/javascript" src="ReadABlob.js"></script>
</head>
<body onload="Initialize()">
	<p id="idText"></p>
</body>
</html>

ReadABlob.js

function Initialize() {
	var qBlob = new Blob(["Reading a blob at XoaX.net"], {type : "text/plain"});
	var qFileReader = new FileReader();
	qFileReader.addEventListener("loadend", function(qEvent) {
		document.getElementById("idText").innerHTML = qEvent.srcElement.result;
	});
	qFileReader.readAsText(qBlob);
}
 

Output

 
 

© 2007–2025 XoaX.net LLC. All rights reserved.