2012-05-02 34 views
0

我有以下的jQuery代碼的問題:JQuery的檢測懸停在Flash對象

$("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> 

預期我沒有收到警報。

+0

你問檢測「Flash對象」,這我的代碼不,不是flash對象的容器。檢測閃存所在的元素(希望閃存將加載的div)並不意味着該閃存已加載或未加載。它只是意味着div(在這種情況下是元素)存在。 – Patriotec

回答

2

嘗試將閃光燈插入某個塊元素並將其懸停而不是該對象。

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

$("#myFlash").hover(function(e){ 
    alert('Flash Here'); 
}); 
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>