简体   繁体   English

Flash JavaScript(Ajax)在IE中不起作用?

[英]Flash JavaScript (Ajax) doesn't work in IE?


I made a Flash application that add's content to a page using JavaScript(Ajax). 我制作了一个Flash应用程序,该应用程序使用JavaScript(Ajax)将内容添加到页面中。 But strangely enough it doesn't work in IE(7 nor 8). 但奇怪的是,它在IE(7或8)中不起作用。 It works fine in Chrome and FireFox. 它在Chrome和FireFox中运行良好。
The JavaScript function is (probably) not the problem, because when I insert javascript:functionName(id); JavaScript函数不是问题所在,因为当我插入javascript:functionName(id); in my browser it works. 在我的浏览器中有效。
In my Flash I use the JavaScript on a button with the following code: 在我的Flash中,我在按钮上使用JavaScript,其代码如下:

getURL("javascript:functionName(id);");

I suppose that, that's a good way to use it? 我想那是使用它的好方法吗?

But strangely enough nothing works in Flash, not even if I replace the code with alert('hello my friend'); 但是奇怪的是,即使我用alert('hello my friend');替换了代码,Flash中也无法正常工作alert('hello my friend'); (maybe he's not my friend?). (也许他不是我的朋友?)。

Could someone help me out and tell me what may be causing the problem? 有人可以帮我一下,告诉我可能是什么原因造成的吗?
Thanks in advance! 提前致谢!

You should be using AS ExternalInterface to communicate with JS, have a look on this: http://www.nelsond8.com/?p=515#more (here I'm using swfobject built in method swfobject.getObjectById , if you are not using swfObject replace this line with document.getElementById ) 您应该使用AS ExternalInterface与JS进行通信,请看以下内容: http : //www.nelsond8.com/? p= 515#more (如果您使用的是此方法,则在这里我使用的是内置于swfobject.getObjectById方法中的swfobject)不使用swfObject将此行替换为document.getElementById

If you are using AS2, you could do something like this: 如果您使用的是AS2,则可以执行以下操作:

<script type="text/javascript">
function myFunction(id)
{
alert('hello my friend');       
return 'hello my friend';

}
</script>

AS2: AS2:

import flash.external.*;

btn.onPress = function() 
    {
        var jsReply:String = String(ExternalInterface.call("myFunction", "01"));

        getURL("jsReply");

        trace(jsReply);
    }

And here is the externalInterface reference page for AS2: http://flash-reference.icod.de/ 这是AS2的externalInterface参考页: http : //flash-reference.icod.de/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM