外部接口在 IE 中不起作用

发布于 2024-07-27 12:25:08 字数 1730 浏览 3 评论 0原文

我试图从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两人的回忆 2024-08-03 12:25:08

我相信您想使用 id,而不是您要添加 swf 的 div:

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

因为您将“mod”设置为 id。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文