为什么我在IE9中从flash到Javascript的调用失败了?

时间:2011-11-18 23:58:33

标签: javascript flash internet-explorer internet-explorer-9

我的Flash应用程序中有几个按钮可以调用两个不同的javascript函数。它们适用于除IE9之外的所有浏览器(我没有尝试过早期的IE)。我调用函数的代码是这样的:

ExternalInterface.call(
        "myLovelyFunction",
        string1, string2);

并且JS中的代码如下所示:

function myLovelyFunction(string1, string2) {
    window.open('https://twitter.com/share?url=http%3A%2F%2Fwww.mysite.com%2Fapage.php&via=atwitteraccount&text=Some%20text%22&related=atwitteraccount',
    'windowname',
    'height=290,width=510');
}

在IE9中,该功能绝对没有任何功能,但控制台抱怨:

SCRIPT438: Object doesn't support property or method 'SetReturnValue' 
index.php, line 1 character 1

第1行,字符1显然没有特别指向任何东西。

我可以通过打开兼容性视图使其工作正常,尽管控制台错误不会消失。

是否有任何关于IE9的信息导致了这一点,更重要的是,我该如何解决这个问题?

2 个答案:

答案 0 :(得分:6)

我也有同样的问题。我使用以下代码:

    <object type="application/x-shockwave-flash" data="/files/banners/64/64_300x250.swf" width="300" height="250">
      <param name="movie" value="/files/banners/64/64_300x250.swf"/>
      <param name="wmode" value="transparent"/>
    </object>

我只是使用常规对象标记嵌入fl​​ash(没有SWFObject,也没有嵌入回退)。我的flash文件通过ExternalInterface调用JS函数window.open,如下所示:

ExternalInterface.call("window.open", url, target, features);

什么行不通: 上面的链接建议将其更改为“document.open”,这不起作用。还尝试强制页面在IE-8模式下呈现不起作用。例如:

<meta http-equiv="X-UA-Compatible" content="IE=8" />

做了什么工作:只需在对象标记中添加“name”和“id”就可以解决问题。例如:

<object type="application/x-shockwave-flash" data="/files/banners/64/64_300x250.swf" width="300" height="250" name="flash_object" id="flash_object">

答案 1 :(得分:1)

完全相同的问题,下面的链接有助于解决它。

http://msdn.microsoft.com/en-us/library/gg622942%28v=VS.85%29.aspx