window.onload函数在Mozilla Firefox上不起作用 [英] window.onload function doesn't work on Mozilla Firefox

查看:676
本文介绍了window.onload函数在Mozilla Firefox上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个网页的加载屏幕,并使用window.onload函数。

除Mozilla Firefox浏览器外,一切都很好。当我们第一次使用ctrl + F5组合访问或刷新页面时,加载屏幕不会消失。如果我们刷新页面只与F5,那么它的作品。

我使用下面的代码

  $(window).load(function(e){
$(#body-mask)。fadeOut(1000,function(){
$(this)。 remove();
});
});

我也尝试了下面的代码,但是没有任何变化。

  window.onload = function(){
$(#body-mask)。fadeOut(1000,function(){
$ this).remove();
});



$ b $ p
$ b为什么会发生这种情况?

请帮忙。



在此先感谢。

解决方案

这个问题是由另一个jQuery插件引起的,这个插件被放置在$(document).ready()函数中。

我在$(window).load()函数中移动它,现在它完美。



我也移动了另一个函数来调整页面加载的图像大小。当它位于$(document).ready()块内部时,如果加载时间过长,有时会出现故障,但现在它也可以工作得很好。 ()函数resizeImages(){
//一些代码
}

$(window).load(function(){
$ ()函数(){
$(this).remove();
});

$ .vegas({
src:backURL,fade:0
});

resizeImages();
});

$(document).ready(function(){
// Some Some code
});


I'm using a loading screen for a webpage and I use window.onload function.

Everything works great except in Mozilla Firefox browsers. When we first visit or refresh the page with ctrl+F5 combination, the loading screen never disappears. if we refresh the page only with F5, then it works.

I use the code below

$(window).load(function(e) {
    $("#body-mask").fadeOut(1000,function(){
        $(this).remove();
    });
});

I have also tried the code below but nothing changed.

window.onload = function () {
   $("#body-mask").fadeOut(1000,function(){
       $(this).remove();
   });
}

Why this is happening?

Please help.

Thanks in advance.

解决方案

The problem is caused by another jquery background plugin which is placed inside $(document).ready()

I moved it inside $(window).load() function, now it works perfect.

I have also moved another function to resize images on the page load. When it was inside $(document).ready() block, sometimes it was malfunctioning if loading time took too long but now it also works great.

function resizeImages(){
    //Some Code
}

$(window).load(function(){
    $("#body-mask").fadeOut(1000,function(){
        $(this).remove();
    });

    $.vegas({
        src: backURL , fade:0
    });

    resizeImages();
});

$(document).ready(function(){
    //Some Other code
});

这篇关于window.onload函数在Mozilla Firefox上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆