我有一个类似于facebook的按钮(iFrame版本),它覆盖在一个完整的浏览器Flash应用程序之上。类似按钮被连接到应用程序中的单独图像,当显示每个新图像时,使用ExternalInterface刷新类似按钮。
like按钮使用JQuery fadeIn()/ fadeOut()逐渐淡入和淡出每个新图像,再次使用ExternalInterface调用。
我遇到的问题是,在Windows上,这似乎并不想在Firefox中工作......
CSS:
html {
height: 100%;
overflow: hidden;
min-width: 800px;
min-height: 600px;
}
#flashContent {
position: absolute;
top: 0px;
left: 0px;
height: 100%;
width: 100%;
z-index: 1;
}
body {
margin: 0;
padding: 0;
background-color: #000000;
}
#fb-like {
position: absolute;
bottom: 32px;
left: 510px;
width: 280px;
z-index: 9999;
display: none;
}
fb-like是包含iFrame的div,它的z-index是9999,只是为了确保它始终位于顶部。
以下是使用的JS:
<script type="text/javascript">
var isVisible = false;
function showLikeButton( visible ){
if( visible == true )
{
$('#fb-like').fadeIn( 'slow' );
isVisible = true;
}
else if ( isVisible )
{
$('#fb-like').fadeOut( 'slow' );
isVisible = false;
}
}
var begOfUrl = "http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fmywebsite.com%2fdirectory";
var endOfUrl = "&layout=button_count&show_faces=false&width=150&action=like&colorscheme=dark&height=21";
function sendIdToLikeButton( title, id ){
$( '#facebook-like' ).attr( 'src', begOfUrl + "%3Fid=" + id + endOfUrl );
}
</script>
其中sendIdToLikeButton方法使用ExternalInterface获取从Flash发送的照片的id,以重新创建iFrame的src属性。
当然,因为这是一个Flash应用程序,所以这里是最小的HTML:
<body>
<div id="fb-like">
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fnfb.designaxiom.com/build13&layout=button_count&show_faces=false&width=150&action=like&colorscheme=dark&height=21" scrolling="no" frameborder="0" style="position: absolute; border:none; overflow:hidden; width:300px; height:40px;" allowTransparency="true" id="facebook-like"></iframe>
</div>
<div id="flashContent">
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
</div>
</body>
同样,除了Windows中的Firefox之外,这种方式无处不在,我不知道如何处理它。我假设它在CSS或Javascript中出错。
非常感谢任何帮助。
提前致谢。
语法
答案 0 :(得分:2)
经过几周的来回,我终于想到了这一点。事实证明问题在于iframe被置于Flash内容之上。
通过在swfobject调用中添加一个参数来解决这个问题 - 将wmode设置为transparent:
var params = {};
params.bgcolor = "#000000";
params.allowfullscreen = "true";
params.allowscriptaccess = "true";
params.wmode = "transparent";
var attributes = { id: "nfb", name:"nfb" };
var swfUrl = "Runner.swf";
swfobject.embedSWF( swfUrl, "flashContent", "100%", "100%", "10.0.0", false, flashvars, params, attributes );
将wmode设置为透明允许在每个浏览器中将“透明”iframe放置在应用程序的顶部。
事实证明这不是像facebook一样的按钮问题,而是使用iframe和Flash。当然,如果您没有使用SWFObject来显示您的swf文件,那么wmode是一个参数,可以在发布swfs时在Flash中的发布属性中设置。
干杯