如何列出 Flash 元素公开的可用回调
有没有办法查询嵌入式 Flash 元素以确定可以通过 JavaScript 在其上执行的可用方法?
编辑: 看起来,在 IE 中,这就像
for ( i in flashNode ) {
alert(i);
}
多次点击后一样简单,它们将成为最后枚举的成员之一。
但在 Firefox 中仍然无法确定这一点。
Is there a way to query an embedded flash element to determine the available methods that can be executed on it via JavaScript?
Edit:
It appears that in IE it's as simple as
for ( i in flashNode ) {
alert(i);
}
After much clicking, they will be some of the very last members enumerated.
Still not able to determine this in Firefox though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然可以通过枚举 IE 中的
这种方法是有问题的,因为属性可以任意添加到任何 DOM 节点。 更糟糕的是,它只能在 IE 中运行。 Firefox(可能还有其他浏览器)不会将回调作为
While it is possible to get the callbacks by enumerating the
<object>
DOM node in IE, they are mixed in with all the other properties of the DOM node and they are unable to be progamatically distinguished without keeping a list of known properties to compare them against and then taking the difference of the two sets.This approach is questionable since properties can be arbitrarily added to any DOM node. Worse, it only works in IE. Firefox (and possibly others) does not return callbacks as a property of the
<object>
DOM node.我相信它在 FF 和其他浏览器中的工作方式相同,但您可能需要以不同于 IE 的方式获取对 swf 元素的引用。
IE 将使用对象标签,通常带有 id,而 ff/safari/etc 将使用嵌入标签,并且由于两个元素上的 id 不应该相同,所以人们通常使用 name 属性而不是 id嵌入标签上的属性。
如果您使用诸如 SWFObject 之类的东西来嵌入您的 swf,那么您应该只获取其中之一(对象或嵌入),并且无论写入哪一个,都会将 id 属性设置为您指定的任何内容,这样您就可以迭代该对象。
I believe it works the same way in FF and other browsers, but you may need to get the reference to your swf element differently than IE.
IE will use an object tag, generally with an id, and ff/safari/etc will use the embed tag, and since you aren't supposed to be the same id on two elements, people generally use the name attribute instead of an id attribute on the embed tag.
If you are using something like SWFObject to embed your swfs, then you should only get one or the other (object or embed) and whichever one gets written will have the id attribute set with whatever you specify, so then you could iterate over the object.