1

I am trying to write a script which displays a loader gif images while the image loads, but none of the images in the page in firefox after including the script. It works fine in chrome. I have included the following code.

Javascript:

<script>
$(window).load(function() {
    $('#loader').hide();
    $('#best').fadeIn();
});
</script>

HTML:

<body>
<div id="loader"></div> 
<div id="best"> 
<!-- Contents of the page here --> 
</div>
</body>

CSS:

#loader {
    background: url('img/19-0.gif');
    height: 95px;
    width: 95px;
    position: relative;
    top: 50%;
    left: 50%;
    margin-top: 15em;
    margin-left: 13em;
}

#best {
    display: none;
}

Is there any problems in my code or should I try an alternative approach?

4

3 回答 3

2

尝试这个:

$(document).ready(function() {
    $('#loader').hide();
    $('#best').fadeIn();
});
于 2013-07-30T11:09:12.617 回答
1

利用

$('document').on("load", function() {

});

而不是$(window).load().

来源:http ://api.jquery.com/on/

于 2013-07-30T11:17:48.347 回答
0

我希望您知道,出于安全原因,Firefox 会阻止用户加载本地脚本和脚本加载的文件?尝试改用本地网络服务器。

于 2013-07-30T11:11:00.240 回答