我遇到加载代码的问题。客户希望在点击标签时显示隐藏的加载器div,并且当(通过单击)其他页面完全加载时,加载器将被隐藏。
这是示例代码
function pageLoaded(){
var hideit = document.getElementById("loadUnload");
hideit.style.display= "none";
}
window.onload = pageLoaded;
function pageUnloaded(){
var showit = document.getElementById("loadUnload");
showit.style.display= "block";
}
window.addEventListener("load", pageLoaded, false);
window.addEventListener("unload", pageUnloaded, false);
window.addEventListener("unbeforeunload", pageUnloaded, false);
window.onload = pageLoaded;
function changeClass(elem, classDark,classSelected) {
for(objIndex = 0; objIndex < elem.parentNode.children.length; objIndex++) {
var obj = elem.parentNode.children[objIndex];
if(obj.className == classSelected) obj.className = classDark;
}
elem.className = (elem.className == classDark)?classSelected:classDark;
elem.children[0].children[0].checked = (elem.className == classSelected) ? true : false;
}
function spinner(){
var lists = document.getElementsByTagName("a");
var spinnerdiv = document.getElementById("loadUnload");
for (var i = 0; i < lists.length; i++)
{
lists[i].onclick = function (){
spinnerdiv.style.display= "block";
}
}
}
and the html code is like that
<**div id="loadUnload">
<**div id="loadingDiv" class="centered"><div class="text">loading...</div></div>
<**/div>