我遇到以下JQuery代码的问题:
$("object").hover(function(e){
alert('Flash Here');
});
我只想让jquery检测我是否悬停在flash对象的顶部。
这是flash嵌入代码:
<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
width="320" height="240" quality="HIGH"><param name="movie"
value="test.swf"><param name="quality" value="high">
<embed src="rdream.swf"
quality="high" width="320" height="240" name="Test"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</object>
我没有按预期收到警报。
答案 0 :(得分:2)
尝试将闪存插入某个块元素并悬停而不是对象。
<div id="myFlash">
<object>
Your Flash...
</object>
</div>
$("#myFlash").hover(function(e){
alert('Flash Here');
});
答案 1 :(得分:1)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<style>
div#container{z-index:2;width:320px;height:240px;}
div#flashcontainer{z-index:1;width:320px;height:240px;overflow:hidden;border:solid 1px red;}
</style>
<script type="text/javascript">
$(document).ready(function(){
//detecting the div container doesnt mean flash was loaded
//$('#flashcontainer').hover(function(){
//alert(this.id);
//});
//detect the id from the flash embed code
$('object').hover(function(){
alert(this.id);
});
});
</script>
<div id="container">
<div id="flashcontainer">
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='320' height='240' id='player1' name='player1'>
<param name='movie' value='test.swf'>
<param name='allowfullscreen' value='true'>
<param name='allowscriptaccess' value='always'>
<param name='wmode' value='transparent'>
<embed id='player1'
name='player1'
src='test.swf'
width='320'
height='240'
allowscriptaccess='always'
allowfullscreen='true'
flashvars="wmode=transparent"
/>
</object>
</div>
</div>