页面加载器问题

发布于 2024-10-31 12:39:25 字数 1456 浏览 0 评论 0原文

我在加载代码时遇到问题。客户希望当单击标签时,将显示隐藏的加载器 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>

i got a problem with loading code. customer wants when clicked an tag a hidden loader div will be shown and when (by clicked) other page completely loaded the loader will be hidden.

here is the sample code

    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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾冷 2024-11-07 12:39:25

我建议您使用 AJAX 和 Jquery。我相信这将是最好的方法,一旦您习惯使用它,它就会解决您的问题。

I recommend you use AJAX and Jquery. I believe this will be the best approach, and it will solve your problem once you get used to working with it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文