1

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

3 Answers 3

6

I found this at http://progproblems.blogspot.com/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 =)

Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

I forgot to mention, we do not own the Flash objects. We are trying to detect clicks that happen on display advertising.
0

Use the YAHOO yui.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.