How to list available callbacks exposed by a flash

2019-06-23 18:07发布

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.

2条回答
对你真心纯属浪费
2楼-- · 2019-06-23 18:44

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.

查看更多
一纸荒年 Trace。
3楼-- · 2019-06-23 18:53

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.

查看更多
登录 后发表回答