问题是在某些浏览器中,flash 捕获了点击事件,而不是通过 DOM 过滤它。对此没有具体的解决方法。
我知道有两种解决方法:
- 将代码添加到处理点击并打开相应 URL 的 swf 文件中
- 在 Flash 顶部放置一个“垫片”不可见链接,该链接可以适当地捕获点击和链接 - 请注意,您的 Flash 文件中只能有其中的一个,因此如果您需要 Flash 文件中的两个链接,它将不起作用。
#2 的例子:
<div id="flashContainer">
<a id="shim" href="mylink.aspx"> </a>
<div id="flash">
<embed class="ads" src="swf/flash_banner.swf" width="315" height="100" wmode="opaque"></embed>
</div>
</div>
#flashContainer {
position: relative;
}
#flash {
z-index: 5;
}
#shim {
display: block;
position: absolute;
top: 0;
left: 0;
width: 315px;
height: 100px;
z-index: 10;
}
更新
#2 使用 div 的示例,使用 jQuery 连接点击事件:
<div id="flashContainer">
<div id="shim"></div>
<div id="flash">
<embed class="ads" src="swf/flash_banner.swf" width="315" height="100" wmode="opaque"></embed>
</div>
</div>
#flashContainer {
position: relative;
}
#flash {
z-index: 5;
}
#shim {
position: absolute;
top: 0;
left: 0;
width: 315px;
height: 100px;
cursor: hand; cursor: pointer;
z-index: 10;
}
$("#shim").click(function() {
window.location.assign("mylink.aspx");
});