0

我在使用以下 JQuery 代码时遇到问题:

$("object").hover(function(e){
   alert('Flash Here');
});

我只想让 jquery 检测我是否将鼠标悬停在 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>

我没有按预期收到警报。

4

2 回答 2

2

尝试将闪光灯插入一些块元素并将其悬停而不是对象。

<div id="myFlash">
  <object>
  Your Flash...
  </object>
</div>

$("#myFlash").hover(function(e){
   alert('Flash Here');
});
于 2012-05-02T10:50:19.087 回答
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>
于 2012-05-02T11:19:03.243 回答