Difference between revisions of "Template:BIT-China/js/base-loading"

Line 1: Line 1:
 
//在页面未加载完毕之前显示的loading Html自定义内容
 
//在页面未加载完毕之前显示的loading Html自定义内容
var _LoadingHtml = '<div id="loadingDiv" style="position:absolute;left:0;top:0;width:calc(100%);height:100%;background-color: #E6E6E6;z-index: 9999;margin:0;padding:0;"><img style="position: absolute;top: calc(50% - 90px);left:calc(50% - 86px);height: 180px;width: 172px;z-index:999999;" src="img/T--BIT-China--iGEM2018-A_img.png"></div>';
+
var _LoadingHtml = '<div id="loadingDiv" style="position:absolute;left:0;top:0;width:calc(100%);height:100%;background-color: #E6E6E6;z-index: 9999;margin:0;padding:0;"><a>loading</a></div>';
 
//呈现loading效果
 
//呈现loading效果
 
document.write(_LoadingHtml);
 
document.write(_LoadingHtml);

Revision as of 18:39, 16 October 2018

//在页面未加载完毕之前显示的loading Html自定义内容

var _LoadingHtml = '
<a>loading</a>
';

//呈现loading效果 document.write(_LoadingHtml);

//监听加载状态改变 document.onreadystatechange = completeLoading;


//加载状态为complete时移除loading效果 function completeLoading() {



   document.documentElement.style.overflow = 'hidden';
   if (document.readyState == "complete") {
       window.onbeforeunload = function () {
           document.documentElement.scrollTop = 0;  //ie下            
           document.body.scrollTop = 0;  //非ie    
       }


       $(window).load(function () {
           $('#loading_all').delay(300).hide(0);
           setTimeout(function () {
               $('body').removeClass("scoll_dis");
           }, 300);
           $.fn.fullpage.setAllowScrolling(false, 'down');
       });
       setTimeout(function () {


           var loadingMask = document.getElementById('loadingDiv');
           loadingMask.classList.add('imgA-nav-gradient-back');
           document.documentElement.style.overflowY = 'auto';
       }, 3000);
       setTimeout(function () {
           var loadingMask = document.getElementById('loadingDiv');
           loadingMask.classList.remove('imgA-nav-gradient-back');
           loadingMask.parentNode.removeChild(loadingMask);
           $.fn.fullpage.setAllowScrolling(true, 'down');
           // body.style="overflow-x:hidden;"         
       }, 4400);
   }
   function newFunction() {
       return false;
   }

}