$(window).load在Firefox中不显示图像

$(window).load does not display images in Firefox

本文关键字:显示 显示图 图像 Firefox window load      更新时间:2023-09-26

我正试图编写一个脚本,在加载图像时显示加载程序gif图像,但在包含脚本后,firefox中的页面中没有任何图像。它用铬处理效果很好。我已经包含了以下代码。

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;
}

我的代码中有问题吗?还是应该尝试其他方法?

试试这个:

$(document).ready(function() {
    $('#loader').hide();
    $('#best').fadeIn();
});

使用

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

而不是CCD_ 1。

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

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