在 Internet Explorer 9 中附加到 ActiveX 事件

发布于 2024-10-19 13:07:15 字数 1214 浏览 1 评论 0原文

我通过 Internet Explorer 中的 HTML 元素嵌入了一个 ActiveX 控件,该控件播放来自 Cisco 视频服务器的视频。

为了让播放器播放,我为 ActiveX 控件的 onPlayerLoaded 事件编写了一个回调函数。

我的代码可以在 IE 7 - 9 中运行,但仅当我使用 Microsoft 专有的 attachEvent 函数时才有效。

JavaScript 示例:

if(this.axClient.attachEvent) 
    { this.axClient.attachEvent("onPlayerLoaded", onPlayerLoadedEventHandler); }

我身上的标准纳粹确实想使用 addEventListener 来代替,就像这样......

if(this.axClient.addEventListener)
    { this.axClient.addEventListener("onPlayerLoaded", onPlayerLoadedEventHandler, false); }
else if(this.axClient.attachEvent) 
    { this.axClient.attachEvent("onPlayerLoaded", onPlayerLoadedEventHandler); }

(从 IE 9 开始,支持 addEventListener。)

不幸的是,当我使用 addEventListener 时>addEventListener 回调函数永远不会被调用。

我在使用 ActiveX 控件方面没有太多经验,因此我假设我可能会忽略它们的一些细微差别。

鉴于 ActiveX 是 Microsoft 专有技术,我们是否应该继续使用 attachEvent 而不是 addEventListener 来处理它们? (ActiveX 中是否有某些固有的东西迫使我们继续使用attachEvent?)

或者这是 AciveX 控件的发布者可以补救的吗? (例如,ActiveX 是否有新的做法可以利用 IE 9 更标准友好的特性。)

或者考虑到 ActiveX 是专有的,我是否应该不要太担心它们的标准......? ;)

I have embeded an ActiveX control via an HTML <option> element in Internet Explorer that plays video from a Cisco video server.

To make the player play I write a callback function for the ActiveX control's onPlayerLoaded event.

The code I have works in IE 7 - 9, but only when I use Microsoft's proprietary attachEvent function.

JavaScript example:

if(this.axClient.attachEvent) 
    { this.axClient.attachEvent("onPlayerLoaded", onPlayerLoadedEventHandler); }

The standard's nazi in me really wants to use addEventListener instead like so ...

if(this.axClient.addEventListener)
    { this.axClient.addEventListener("onPlayerLoaded", onPlayerLoadedEventHandler, false); }
else if(this.axClient.attachEvent) 
    { this.axClient.attachEvent("onPlayerLoaded", onPlayerLoadedEventHandler); }

(Starting with IE 9, addEventListener is supported.)

Unfortunately when I use addEventListener the callback function never gets called.

I do not have a lot of experience with consuming ActiveX controls, so I'm assuming there are some nuances about them that I might be missing.

Given that ActiveX is a Microsoft proprietary technology is it a fair assumption that we should continue to use attachEvent instead of addEventListener with them? (Is there something inherent in ActiveX that forces us to continue using attachEvent?)

Or is this something the publisher of the AciveX control can remedy? (For example, are there new practices for ActiveX that take advantage of IE 9 more standard-friendly nature.)

Or given that ActiveX is proprietary, should I just not worry too much about standards with them ...? ;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那小子欠揍 2024-10-26 13:07:15

我在尝试使 addEventListener 与我的 FireBreath 插件一起使用时研究了同样的问题。由于 FireBreath 插件适用于所有主要浏览器,因此我很高兴在 IE9 中添加事件监听器支持,以便一切都可以完全相同。

想象一下,当我发现在对象上调用 addEventListener 时,插件/activex 控件上的任何 API 都没有被调用或以任何方式通知时,我感到多么震惊。 AttachEvent 使用 ActiveX 控件上称为 Connection Points 的接口,在 Firefox 上我们必须自己实现 addEventListener 和 removeEventListener 方法,但在 IE9 上它只是拦截这些调用,不返回错误,然后它们就消失了。

{讽刺}太棒了!微软干得好!{/讽刺}

I looked into this same question while trying to make addEventListener work with my FireBreath plugins. Since FireBreath plugins work on all major browsers, I was excited that in IE9 addEventListener support would make it so that everything could work exactly the same.

Imagine my shock when I discovered that none of the APIs on the plugin/activex control -- none of them -- were called or notified in any way when addEventListener was called on the object. attachEvent uses an interface on the ActiveX control called Connection Points, and on Firefox we have to implement the addEventListener and removeEventListener methods ourselves, but on IE9 it just intercepts those calls, doesn't return an error, and they disappear into the void.

{sarcasm}Amazing! Way to go Microsoft!{/sarcasm}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文