为我的网站创建Loader

Create Loader for my website

本文关键字:Loader 创建 网站 我的      更新时间:2023-09-26

我正在尝试为我的网站创建加载程序,但它不起作用。我使用的是经典涡轮链接进行此操作。加载程序在页面加载后加载,这是我不想要的。我需要当页面加载时,我需要我的加载程序加载,当页面加载后,加载程序应该消失,这两件事都不起作用。这是我的代码

 <div id="content-wrapper">
        <div class="loader"><img src='/assets/gionee-loader.gif' style='width:100px;height:100px;margin-left:30%;margin-top:10%;display:block;'/></div>
        <div class="row">
            <div class="col-lg-12">
                <div class="main-box clearfix">
                    <div class="clearfix">
                       <div class="common_page gsb1">
                           <div class="hdr">
                               <div class="row">
                                    <div class="col-md-3">
                                      <h4>Dashboard</h4>
                                    </div>
                                <div class="col-md-5">
                                </div>
                                <div class="col-md-4 pull-right">
                                    <%=render 'common/date'%>
                                </div>                
                            </div>    
                        </div> 
                    </div>
                </div>
            </div>
        </div>
    </div>
          <center>
<div class="table-responsive custom-bg">
<table class="custom-table" cellspacing="0">
<tr>
<td><table width="100%" border="0" class="tbl-second-lvl" cellspacing="0" cellpadding="0">
  <tr>
    <td> Name</td>
    <td>Email </td>
    </tr>
<tr></tr>
 <%@dashboard.each do |dashboard|%>
  <tr>
    <td><b><%=dashboard[:NAME]%></b></td>
    <td><%=dashboard[:email]%></td>

  </tr>
  <%end%>


</table></td>  
</tr>
</table>
<%= will_paginate @dashboard %>
</div>
</center>
          <%=render 'common/footer'%>
   </div>
 <script>
    $("#retailer").attr("class","active")

    $(document).on('page:load', function(event) {
      $('.loader img').css("display","none"); 
    });

  </script>   

但是加载程序没有加载图像。有人能告诉我怎么做吗。我不想用ajax来做这件事

将显示设置为最初阻止:-

         <div class="loader"><img src='/assets/gionee-loader.gif' style='width:100px;height:100px;margin-left:30%;margin-top:10%;display:block;'/></div>

或者只是

<div class="loader"><img src='/assets/gionee-loader.gif' style='width:100px;height:100px;margin-left:30%;margin-top:10%;'/></div>

并删除

$(document).on('page:before-unload', function(event) {
//remove  $('.loader img').css("display","block");
});

因此,在文档完全加载后,加载程序图像将不可见,但在之前是可见的