最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Detecting Flash "Click" Event in JavaScript Across Browsers - Stack Overflow

programmeradmin1浏览0评论

Is there a way JavaScript can detect clicks (or mousedown, mouseup) that happen on Flash objects?

I have tried:

  • Attaching the 'mouseup', 'mousedown', and 'click' events to the Flash object using attachEvent/addEventListener
  • Directly attaching the 'onmouseup', 'onmousedown', 'onclick' events inline on the Flash object
  • Switching from event 'bubbling' to event 'capturing' (only works in Firefox/Safari)

I need this to work in IE6+, Firefox 2+, and Safari 3+.

Thanks for any help! -Dave

Is there a way JavaScript can detect clicks (or mousedown, mouseup) that happen on Flash objects?

I have tried:

  • Attaching the 'mouseup', 'mousedown', and 'click' events to the Flash object using attachEvent/addEventListener
  • Directly attaching the 'onmouseup', 'onmousedown', 'onclick' events inline on the Flash object
  • Switching from event 'bubbling' to event 'capturing' (only works in Firefox/Safari)

I need this to work in IE6+, Firefox 2+, and Safari 3+.

Thanks for any help! -Dave

Share Improve this question edited Jul 21, 2009 at 14:32 asked Jul 21, 2009 at 14:27 ArtzStudioArtzStudio
Add a ment  | 

3 Answers 3

Reset to default 6

I found this at http://progproblems.blogspot./2009/08/javascript-onclick-for-flash-embeded.html

1) Set the param wmode to transparent. This allows the object containing the flash to receive the javascript onclick.
2) Use onmousedown insted of onclick. In spite of using wmode transparent, some browsers still wont call  the onclick, but they do call onmousedown.
The code looks like this:

<div onmousedown="clickBanner(1)">
<object>
<param name="movie" value="3.swf">
<param name="wmode" value="transparent" />
<embed wmode=transparent allowfullscreen="true" allowscriptaccess="always" src="3.swf"></embed>
</object>
</div>

It work for my needs =)

Do you own the flash objects?

We implemented call-backs from Flash to JavaScript when flash detects clicks. But we own the flash app and can manage the interaction.

Use the YAHOO yui.

If ( YAHOO.deconcept.SWFObjectUtil.getPlayerVersion().major == 0 ) {
  alert("error");
}
发布评论

评论列表(0)

  1. 暂无评论