点击Flash时,某些浏览器中的事件不会冒泡 [英] Event not bubbling in some Browsers when clicked on Flash

查看:119
本文介绍了点击Flash时,某些浏览器中的事件不会冒泡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:
Windows 7,
Internet Explorer 8,
Flash ActiveX 10.1.53.64,
wmode =透明

Environment: Windows 7, Internet Explorer 8, Flash ActiveX 10.1.53.64, wmode=transparent

刚刚写了一个小测试页面,您可以在IE和Firefox或任何其他浏览器中加载。

Just wrote a small test page that you can load in IE and Firefox or any other Browser.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Event bubbling test</title>
  </head>
  <body onclick="alert('body');" style="margin:0;border-width:0;padding:0;background-color:#00FF00;">
    <div onclick="alert('div');" style="margin:0;border-width:0;padding:0;background-color:#FF0000;">
      <span onclick="alert('span');" style="margin:0;border-width:0;padding:0;background-color:#0000FF;">
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/get/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="159" height="91" id="flashAbout_small" align="absmiddle">
          <param name="movie" value="http://www.adobe.com/swf/software/flash/about/flashAbout_info_small.swf"/>
          <param name="quality" value="high"/>
          <param name="bgcolor" value="#FFFFFF"/>
          <param name="wmode" value="transparent"/>
          <embed src="http://www.adobe.com/swf/software/flash/about/flashAbout_info_small.swf" quality="high" bgcolor="#FFFFFF" width="159" height="91" wmode="transparent" name="flashAbout_small" align="absmiddle" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"/>
        </object>
      </span>
    </div>
  </body>
</html>

所以点击任何彩色的形状应该会产生一个警报(除了IE中的绿色,不知道为什么但是我希望这是不对的话题,与我的问题无关)。

So clicking any colored shape should produce an alert (except for the green one in IE, not sure why but I hope that's off topic and not related to my issue).

点击Firefox中的Flash容器会工作得很好。您应该按照这个顺序获取警报框,其中包含:span,div和body。 Flash将事件泡在HTML上。但是这不是在IE中发生的。

Clicking the Flash container in Firefox will work Perfectly fine. You should get alert boxes in this order containing: span, div and body. Flash bubbles the event to the HTML. But this is not happening in IE.

那么为什么IE中的Flash不会冒泡到HTML?

So why is Flash in IE not bubbling events to HTML?

编辑:如Andy E所述,这个行为也可以在谷歌浏览器中看到,据我所知,我没有使用ActiveX将Flash影片嵌入页面。

As mentioned by Andy E this behavior can also bee seen in Google Chrome which to my knowledge is not using ActiveX to embed the flash movie into the page.

推荐答案

Internet Explorer中的Flash是一个ActiveX控件 - ActiveX控件消耗事件,但不要在托管它们的对象元素上触发它们。这意味着没有DOM事件会爆发。 FWIW,Google Chrome的行为方式相同。

Flash in Internet Explorer is an ActiveX control - ActiveX controls consume events but don't fire them on the object element hosting them. This means there is no DOM event to bubble up. FWIW, Google Chrome behaves the same way.

这篇关于点击Flash时,某些浏览器中的事件不会冒泡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆