1
votes

I would want to catch click with javascript on a embed flash object on my page. I used wmode="opaque" (tried transparent too) and put a low z-index. I tried catching click on a div, on the object element and on the embed element.
On FF (5), all three of them work. On IE (7 & 8), none of them work.

Here's my code (I removed some attribute for flash like type or classid) :

<div onclick="javascript:alert('div.click');" style="z-index:10;">
    <object onclick="javascript:alert('object.click');" style="z-index:1;">
        <param value="flash.swf" name="movie">
        <param value="opaque" name="wmode">
        <embed onclick="javascript:alert('embed.click');" wmode="opaque" src="flash.swf">
    </object>
</div>

Second solution

A also tried to put the div after the object element with "top:-100px;" to be on top on the flash. In IE, it works if the div is in plain color (like bg-color:red) but not if it has a transparent background :

<object onclick="javascript:alert('object.click');" style="z-index:1;">
    <param value="flash.swf" name="movie">
    <param value="opaque" name="wmode">
    <embed onclick="javascript:alert('embed.click');" wmode="opaque" src="flash.swf">
</object>
<div onclick="javascript:alert('div.click');" style="height:100px; top:-100px; position:relative; background-color:Transparent; z-index:10;">
</div>
  • Do I have any chance to make it work with Internet Explorer ? Thank you.
1

1 Answers

2
votes

Modify div so it has back color set and transparent in fact using opacity. The click will be cought inside div element. Works well in ie, chrome, ff.

background-color: white;
opacity: 0;
-moz-opacity: 0;
filter: alpha(opacity = 0);