簡體   English   中英

jQuery在Flash對象上檢測到懸停

[英]JQuery Detecting Hover on Flash Object

我對以下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>

我沒有收到預期的警報。

嘗試將Flash插入某個塊元素,然后將其懸停在該對象上,而不是將其懸停在該對象上。

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM