CSS / JS加载页面时显示加载器

时间:2016-08-03 09:52:01

标签: javascript css

如何在加载页面时显示加载程序

我认为JS功能是

onload="myFunction()"

使用css加载器:http://jsfiddle.net/33zch/60/

3 个答案:

答案 0 :(得分:1)

这样的事情:

<script type="text/javascript">
$(window).load(function() {
    $(".hoja").fadeOut("slow");
})
</script>

答案 1 :(得分:1)

//html <body onload='hideLoader()'> <div id='loader' class="hoja">Loading...</div> </body> //js window.hideLoader = function(){ var loader = document.getElementById('loader'); loader.style.display='none'; } 上的javascript中添加DECLARE @curEmployee CURSOR; DECLARE @iEmpID BigINT DECLARE @vEmployeeName Varchar(50), @EmployeeContact Varchar(50) BEGIN SET @curEmployee = CURSOR LOCAL READ_ONLY FAST_FORWARD FOR select EmployeeID,EmployeeName, EmployeeContact from dbo.Employee OPEN @curEmployee FETCH NEXT FROM @curEmployee INTO @iEmpID, @vEmployeeName, @EmployeeContact WHILE @@FETCH_STATUS = 0 BEGIN PRINT Cast (@iEmpID as Varchar(10)) + ' - ' + @vEmployeeName + ' - ' + @EmployeeContact -- Here Write the code based on @iEmpID FETCH NEXT FROM @curEmployee INTO @iEmpID, @vEmployeeName, @EmployeeContact END CLOSE @curEmployee DEALLOCATE @curEmployee END 函数,这将执行隐藏加载程序的逻辑

Cross Reference and Model Information

小提琴:http://jsfiddle.net/33zch/61/

使用setTimeout显示效果:http://jsfiddle.net/33zch/63/(感谢Moob)

答案 2 :(得分:0)

试试这个

window.onload = function(){
   document.getElementsByClassName('hoja')[0].style.opacity = '0';
}

window.onload = function(){
   document.getElementsByClassName('hoja')[0].style.display = 'none';
}

正在使用 JSFiddle