Jquery 使用页面导航预加载gif图像
大家好,我需要一个预加载gif,但我的情况是,当我点击 在导航到下一页的菜单按钮上,它应该一直启动到 将显示下一页,并在下一页加载后关闭。如果 有任何插件或任何类型的代码,你们可以提供我会 非常感谢 这是我用来显示预加载程序的代码Jquery 使用页面导航预加载gif图像,jquery,ajax,preload,Jquery,Ajax,Preload,大家好,我需要一个预加载gif,但我的情况是,当我点击 在导航到下一页的菜单按钮上,它应该一直启动到 将显示下一页,并在下一页加载后关闭。如果 有任何插件或任何类型的代码,你们可以提供我会 非常感谢 这是我用来显示预加载程序的代码 <script type="text/javascript"> jQuery(document).ready(function($) { $(window).load(function(){ $('#myloader').
<script type="text/javascript">
jQuery(document).ready(function($) {
$(window).load(function(){
$('#myloader').fadeOut('slow',function(){$(this).remove();});
$('body').delay(350).css({'overflow':'visible'});
});
});
</script>
jQuery(文档).ready(函数($){
$(窗口)。加载(函数(){
$('#myloader').fadeOut('slow',function(){$(this.remove();});
$('body').delay(350).css({'overflow':'visible'});
});
});
试试这样的方法(注释中有解释):
(函数($){
$(文档).ready(函数(){
//文档已准备好,隐藏加载程序,不要删除,因为我们希望稍后将其返回
$('#myloader').fadeOut('slow',function(){
//显示滚动条你确定你在这个脚本之前添加了jQuery吗?是的@ron它在那里我必须做一些修改才能使它工作…现在它工作了谢谢@ron
( function( $ ) {
$( document ).ready( function() {
// document is ready, hide loader, don't remove since we want it back later
$( '#myloader' ).fadeOut( 'slow', function() {
// show scrollbar <- flaw in design!
$( 'body' ).css( { 'overflow' : 'visible' } );
} );
// when user clicks on a link with class hide-loader
$( 'a.hide-loader' ).on( 'click', function( event ) {
// don't follow the link, we want an animation first
event.preventDefault();
// show loader again
$( '#myloader' ).fadeIn( 'slow', function() {
// follow the link
window.location = $( this ).attr( 'href' );
} );
} );
} );
} )( jQuery );