JSFiddle - React, Tailwind, and code Playground
HTML
<div id="log"></div>
JavaScript
function $(id) {
return document.getElementById(id);
}
function nacti(url, callback)
{
var xhr = new XMLHttpRequest();
xhr.open("HEAD", url, true);
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4 && xhr.status == 200)
callback(xhr);
};
xhr.send("");
}
var odkazy = [ "http://fiddle.jshell.net/favicon.png", "http://fiddle.jshell.net/css/style.css" ];
var getSize = [];
$('log').innerHTML += 'vypis odkazu: ' + odkazy + '<br>';
for (var i in odkazy) {
(function(idx) {
nacti(odkazy[idx], function(xhr) {
getSize[idx] = xhr.getResponseHeader("Content-Length");
if (odkazy.length == getSize.length) {
// hotovo, zavolám funkci pro výpis jmen souborů a velikostí
var url = odkazy;
$('log').innerHTML += 'velikost souboru: ' + getSize + '<br>';
}
});
})(i);
};