[英]Calling a custom FLASH method from IE7 & IE8
I am trying to call a custom method of an embedded flash like so: 我试图像这样调用嵌入式Flash的自定义方法:
var flash = navigation_get_flash_movie_object('main'); var flash = navigation_get_flash_movie_object('main'); if (flash) { flash.continentOut(id); 如果(flash){flash.continentOut(id); } }
Which works great in Chrome ans Safari, but fails utterly in IE7 & IE8. 在Chrome ans Safari中效果很好,但在IE7和IE8中却完全失败。 The browsers throws an error that the object doesn't have such a method. 浏览器抛出一个错误,该对象没有这种方法。
I am using the example from http://www.permadi.com/tutorial/flashjscommand/ , and now that I've tested it, it also fails at it's testing page as well http://www.permadi.com/tutorial/flashGetObject/ 我正在使用http://www.permadi.com/tutorial/flashjscommand/中的示例,现在,我已经对其进行了测试,但它在测试页面以及http://www.permadi.com/tutorial上也失败了/ flashGetObject /
Does anyone have a better way to invoke custom functions in a Flash object from Javascript? 有谁有更好的方法从Javascript调用Flash对象中的自定义函数?
Check out the ExternalInterface API Docs . 请查看ExternalInterface API文档 。 They use this method: 他们使用这种方法:
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
}
So you would do this: 因此,您可以这样做:
var flash = thisMovie('main'); if (flash) { flash.continentOut(id); }
(I'm assuming of course that you're using ExternalInterface.addCallback()
to define continentOut
) (我当然假设您正在使用ExternalInterface.addCallback()
来定义continentOut
)
Here's another option: 这是另一个选择:
function thisMovie(movieName) {
return document[movieName] || window[movieName];
}
Personally, this seems better because it doesn't use browser sniffing and would be future-compatible, but that's just me. 就个人而言,这似乎更好,因为它不使用浏览器嗅探,并且可以与将来兼容,但这仅是我自己。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.