这很简单。Adobe AIR 应用程序的主窗口是一个 html 文件,application.xml 如下所示:
<initialWindow>
<title>window title</title>
<content>index.html</content>
index.html 看起来像这样:
<script type="text/javascript"
src="http://www.mysite.com/mybanner.js" id="add"></script>
<script type="text/javascript">
document.write("<h1>this is strange</h1>");
alert(document.getElementById("add").src);
function getJS(){
document.getElementById("add").src="http://www.mysite.com/mybanner.js";
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://www.mysite.com/mybanner.js"
,false);
xmlhttp.send(null);
if (xmlhttp.status === 200) {
alert(xmlhttp.responseText);
eval(xmlhttp.responseText);
}else{
throw("Can't open url, response status is:"+xmlhttp.status);
}
}
</script>
<input type="button" onclick="getJS();" value="getJS" />
打开应用程序时,它显示“这很奇怪”并提醒其他脚本标签(横幅)的来源,但不显示任何内容。单击 getJS 按钮会提醒 js 文件的内容,但仍然不显示任何内容。eval 导致 AIR 运行时安全违规。在 Internet Explorer 或 Firefox 中打开文件会显示横幅,因此脚本或 src 中没有错误。
我在 flashDevelop 中运行它并且在输出中看不到任何警告或错误,可以使用 xmlhttprequest 连接到任何站点(通常在浏览器中不允许)但无法从服务器加载简单的 js 文件。
谁能帮我解决这个问题?