外部接口在 IE 中不起作用
我试图从 javascript:
as:
function testExternalConnection(str:String):Void {
_root.debug.htmlText = "testExternalConnection ok";
}
ExternalInterface.addCallback("testExternalConnection", this, testExternalConnection);
js:
var movie = getFlashMovie("ap1_mod_hidden")
movie.testExternalConnection();
这里
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
调用 flash 对象中的操作,我使用 swfobject: 包含我的 flash:
<span id="ap1_mod_hidden"></span>
<script type="text/javascript">
// Setting up the flash player
var flashvars = {
mp3Path: "stop",
artistName : "",
trackName : ""
};
var params = {
codebase: 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
src: '/flash/ap1_mod.swf',
quality: 'high',
pluginspage: 'http://www.macromedia.com/go/getflashplayer',
scale: 'showall',
devicefont: 'false',
bgcolor: '#999999',
name: 'ap1_mod',
menu: 'true',
id: 'mod',
allowFullScreen: 'false',
allowScriptAccess:'always', //sameDomain
movie: '/flash/ap1_mod.swf',
wmode: "transparent",
allowfullscreen: "true"
};
swfobject.embedSWF("/flash/ap1_mod.swf", "ap1_mod_hidden", "300", "300", "9.0.0", false, flashvars, params);
</script>
没什么疯狂的。 所以这段代码在所有地方都工作正常,但在 Internet Explorer 中却不行(真是令人惊讶:\)。 它正确获取电影对象,但无法调用外部接口函数。 据说该属性未定义。
我在谷歌上查看过,但没有成功......任何帮助将不胜感激!
I am trying to call an action in a flash object from the javascript:
as:
function testExternalConnection(str:String):Void {
_root.debug.htmlText = "testExternalConnection ok";
}
ExternalInterface.addCallback("testExternalConnection", this, testExternalConnection);
js:
var movie = getFlashMovie("ap1_mod_hidden")
movie.testExternalConnection();
with
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
I'm including my flash using swfobject:
<span id="ap1_mod_hidden"></span>
<script type="text/javascript">
// Setting up the flash player
var flashvars = {
mp3Path: "stop",
artistName : "",
trackName : ""
};
var params = {
codebase: 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
src: '/flash/ap1_mod.swf',
quality: 'high',
pluginspage: 'http://www.macromedia.com/go/getflashplayer',
scale: 'showall',
devicefont: 'false',
bgcolor: '#999999',
name: 'ap1_mod',
menu: 'true',
id: 'mod',
allowFullScreen: 'false',
allowScriptAccess:'always', //sameDomain
movie: '/flash/ap1_mod.swf',
wmode: "transparent",
allowfullscreen: "true"
};
swfobject.embedSWF("/flash/ap1_mod.swf", "ap1_mod_hidden", "300", "300", "9.0.0", false, flashvars, params);
</script>
Nothing crazy here. So this code is working fine in everything but not in Internet Explorer (what a surprise :\ ). It is getting the movie object correctly but it is not able to call the externalinterface function. It's saying that the property is not defined.
I've looked on google and SO with no success... any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您想使用 id,而不是您要添加 swf 的 div:
因为您将“mod”设置为 id。
I believe you want to use the id, not the div you're adding the swf too so:
since you're setting "mod" as the id.