在我的网站上,我在div中有一个SWF,它覆盖了我的logo png图像。我希望这个包含SWF的div仅在使用jQuery加载徽标图像后出现。
overlay.php包含SWF代码
<div id="overlay"><?php include "overlay.php"?></div>
<div id="logo"></div>
jQuery的:
<script type="text/javascript">
$('#header').on('load',function(){
$('#overlay').css("visibility","visible");
});
</script>
的CSS:
#overlay{
position:absolute;
z-index:2;
visibility:hidden;
}
头
#header{
background-image:url(logo.png);
background-repeat:no-repeat;
position:relative;
z-index:1;
}
答案 0 :(得分:2)
您可以添加一个侦听图像加载的事件:
$('img').on('load',function(){
$('#overlay').show();
});
当然,您需要先隐藏div
并将img
更改为相应的id
或class
。与div
相同。
如果您的图片是background-image
,可以试试这个:
$('<img>').attr('src',function(){
var imgUrl = $('#header').css('background-image');
imgUrl = imgUrl.substring(4, imgUrl.length-1);
return imgUrl;
}).load(function(){
$('#overlay').show();
});