ExternalInterface.call使用ActionScript" EVAL"只能在Firefox没有镀铬 [英] ExternalInterface.call using actionscript "eval" only works in firefox not chrome

查看:132
本文介绍了ExternalInterface.call使用ActionScript" EVAL"只能在Firefox没有镀铬的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Chrome不希望让我访问从SWF文件的javascript直接在地址栏(我知道这是不是最好的做法,但是这就是我试图完成):

Chrome doesn't want to let me access javascript from swf file directly in the URL bar (I know that isn't best practice, but that's what I am trying to accomplish):

由于:

/file.swf?cmd=alert();

通过以​​下code(片段):

With the following code (snippet):

flash.external.ExternalInterface.call("eval", cmd);

这在Firefox而不是Chrome浏览器才可以。我采取这种方法,因为在Chrome运行JS的ActionScript 2的方法是使用的getURL(JavaScript的:....,但是这并不能在Chrome工作之一了。

This only works in Firefox and not in Chrome. I am taking this approach because in chrome the actionscript 2 way to run JS was to use getURL("Javascript:...., however this doesn't work in Chrome either anymore.

有没有解决这个办法(通过直接在相对于被嵌入在页面的浏览器调用文件?) - 我有我的理由

Is there a way around this (by calling the file directly in the browser as opposed to be embedded in a page?)- I have my reasons!

推荐答案

尝试创建一个自定义函数代理了的eval功能。 在JS试试这个...

Try creating a custom function the proxies the 'eval' function. Try this in JS...

function exec_code( $value ) {

    window.eval( $value );
}

...这为。

... and this in AS.

var value:String = "[JavaScript Code to execute]";
if ( ExternalInterface.available ) ExternalInterface.call( 'exec_code', value );

这篇关于ExternalInterface.call使用ActionScript" EVAL"只能在Firefox没有镀铬的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆