使用jQuery跟踪flash电影(对象/嵌入)的单击

我正在制作一个动态横幅系统,可以处理img横幅,以及使用object / embed完成的flash横幅。 整个网站大量使用jQuery,包括处理“点击”事件。

在跟踪图像本身的点击时,这显然不是问题(我跟踪父DIV标签上的点击。但是,当广告是SWF时,它会失败,因为我怀疑它会。

是否有一个jQuery解决方法,允许我使用DOM捕获Flash元素的单击?

如果您可以访问SWF源,则可以使用ExternalInterface与包含的html页面进行通信。

 //inside the flash movie: stage.addEventListener(MouseEvent.CLICK, onClick); function onClick(e:MouseEvent):void { ExternalInterface.call("handleFlashClick", [parameters to the method]); } //javascript in the containing html page function handleFlashClick() { //call the jQuery method here. } 

我知道这是很久以前发布的,已经回答了,但我只想为未来的网站访问者添加一个更简单的解决方案。 虽然嵌入的SWF文件将吞下onclick事件,但它不会吞下onmousedown事件。 诀窍是在param标签和embed标签中将wmode设置为透明。

 

您可以使用jQuery绑定到mousedown事件,如下所示:

 $('#layer1').mousedown(function() { alert('mouse down'); }); 

我能够通过以下方式获取webwires的答案并获得对象点击工作。

 // Podcast player GA event tracking var podcast_player = $('object.podcast-player'); if( podcast_player.length > 0 ) { podcast_player.live('mousedown',function(){ _gaq.push(['_trackEvent', 'Podcast', 'Play']); }); } 

我希望这可以帮助其他人,感谢网络