ExternalInterface.call使用ActionScript" EVAL"只能在Firefox没有镀铬镀铬、只能在、ActionScript、call

2023-09-08 11:49:47 作者:じ☆為い愛沉淪

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 );
 
精彩推荐
图片推荐