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

izb*_*izb 5 javascript flash internet-explorer internet-explorer-9

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

ExternalInterface.call(
        "myLovelyFunction",
        string1, string2);
Run Code Online (Sandbox Code Playgroud)

并且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');
}
Run Code Online (Sandbox Code Playgroud)

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

SCRIPT438: Object doesn't support property or method 'SetReturnValue' 
index.php, line 1 character 1
Run Code Online (Sandbox Code Playgroud)

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

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

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

Jer*_*ght 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>
Run Code Online (Sandbox Code Playgroud)

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

ExternalInterface.call("window.open", url, target, features);
Run Code Online (Sandbox Code Playgroud)

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

<meta http-equiv="X-UA-Compatible" content="IE=8" />
Run Code Online (Sandbox Code Playgroud)

做了什么:只需在对象标签中添加"名称"和"id"即可解决问题.例如:

<object type="application/x-shockwave-flash" data="/files/banners/64/64_300x250.swf" width="300" height="250" name="flash_object" id="flash_object">
Run Code Online (Sandbox Code Playgroud)