I'm trying to do that "Loading" effect when the user accesses the MAIN PAGE ONLY, but I'm not able to
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>