开发者

Elegant way to get ExternalInterface working with all browsers

I want to call a function inside a Flash movie from javascript, using the ExternalInterface class. The problem is that to get it to work with Firefox I need to use the embed element and with the rest I have to get the object element. To solve it, I gave different ids to that two elements and depending on the user agent I select one or the other:

 function getMovie(movieName) {

    alert(navigator.userAgent);
     if (navigator.userAgent.indexOf("Firefox") != -1) {
         return document["flash_embed"];
     } else {
         return document["flash_object"];
     }
 }

This works, but it is not very elegant and it may not work with other browsers... Do you 开发者_StackOverflowknow a better way to do this?


Use swfobject to embed your flash movie, and then use it to retrieve the correct id.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜