ExternalInterface不能在IE中工作

ExternalInterface不能在IE中工作

本文介绍了ExternalInterface不能在IE中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



<$ p

我试图从javascript:

中调用Flash对象中的动作。 $ p $ 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)?窗口[movieName]:document [movieName];



$ b $ p
$ b我使用swfobject包含了我的flash:

 < span id =ap1_mod_hidden>< / span> 
< script type =text / javascript>
//设置flash播放器
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',
质量:'high',
pluginspage:'http://www.macromedia.com/go/getflashplayer',
比例:'showall',
devicefont:'false',
bgcolor:'#999999',
名称:'ap1_mod',
菜单:'true',
id:'mod',
allowFullScreen:'false',
allowScriptAccess:'always',// sameDomain
movie:'/flash/ap1_mod.swf',
wmode: 透明,
allowfullscreen:true
};

swfobject.embedSWF(/ flash / ap1_mod.swf,ap1_mod_hidden,300,300,9.0.0,false,flashvars,params);
< / script>

这里没什么疯狂的。所以这段代码在所有事情上都可以正常工作,但是在Internet Explorer中却不行(真是一个惊喜:\)。它正确地获取电影对象,但不能调用externalinterface函数。这是说,该属性没有定义。

我已经看过谷歌和所以没有成功...任何帮助将不胜感激!

解决方案

我相信你要使用id,而不是你添加swf的div,所以:

  function getFlashMovie(movieName){
return swfobject.getObjectById(mod);
}

因为您将mod设置为id。


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!

解决方案

I believe you want to use the id, not the div you're adding the swf too so:

function getFlashMovie(movieName) {
    return swfobject.getObjectById("mod");
}

since you're setting "mod" as the id.

这篇关于ExternalInterface不能在IE中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 01:55