0
I’m trying to do that "Loading" effect when the user accesses ONLY THE MAIN PAGE, but I’m not getting it
CSS:
#load {background:url(http://www.ajaxload.info/cache/FF/FF/FF/00/00/00/1-0.gif) no-repeat center;background-color:#fff;width:100%;height:100%;position:fixed;left:0;top:0;z-index:1000;}
Javascript:
function GetXmlHttpObject() {
var xmlHttp=null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function request() {
myRequest = GetXmlHttpObject();
url = '/';
myRequest.open('GET',url,true);
myRequest.onreadystatechange = function() {
if(myRequest.readyState == 4 && myRequest.status == 200) {
document.getElementById('load').style.display = 'none';
}
}
myRequest.send(null);
}
HTML:
<div id="load"></div>
You put the file/address path in your url ? why I just put a valid address here and it worked :)
– Gabriel Rodrigues
window.addeventlistener("load", Function(){ var load = Document.getElementById("load"); Document.body.removeChild(load);});
– Guilherme15990
I solved my problem
– Guilherme15990