I've been trying to build my own (small) framework in JavaScript for an AIR application and I've run into a peculiar problem: I can't find a way for a JavaScript file to load another. It seems the only way to load JavaScript is for an HTML file to load it.
我一直在尝试使用JavaScript为AIR应用程序构建自己的(小)框架,我遇到了一个特殊的问题:我找不到一种方法让JavaScript文件加载另一个。似乎加载JavaScript的唯一方法是加载HTML文件。
Is this correct? Is there really no way for a JavaScript file to load another?
它是否正确?是否真的没有办法让JavaScript文件加载另一个?
2 个解决方案
#1
The security restrictions in Application Sandbox mode do not allow instantiating any new JavaScript code after the load event (during that event you can still load and evaluate JS).
Application Sandbox模式中的安全限制不允许在load事件之后实例化任何新的JavaScript代码(在该事件期间,您仍然可以加载和评估JS)。
As for the loading data, you should be able to use XHR to retrieve any text data you want at any moment of time without any restrictions.
至于加载数据,您应该能够使用XHR在任何时刻检索您想要的任何文本数据而没有任何限制。
#2
Have you tried creating a script element, setting the src attribute, and adding it to the document body? I don't think the usual document.write() trickery works but I'm pretty sure adding a script element should.
您是否尝试过创建脚本元素,设置src属性并将其添加到文档正文中?我不认为通常的document.write()技巧有效,但我很确定添加一个脚本元素应该。
(I believe all paths are relative to the root of the Air application itself.)
(我相信所有路径都与Air应用程序本身的根相对。)
#1
The security restrictions in Application Sandbox mode do not allow instantiating any new JavaScript code after the load event (during that event you can still load and evaluate JS).
Application Sandbox模式中的安全限制不允许在load事件之后实例化任何新的JavaScript代码(在该事件期间,您仍然可以加载和评估JS)。
As for the loading data, you should be able to use XHR to retrieve any text data you want at any moment of time without any restrictions.
至于加载数据,您应该能够使用XHR在任何时刻检索您想要的任何文本数据而没有任何限制。
#2
Have you tried creating a script element, setting the src attribute, and adding it to the document body? I don't think the usual document.write() trickery works but I'm pretty sure adding a script element should.
您是否尝试过创建脚本元素,设置src属性并将其添加到文档正文中?我不认为通常的document.write()技巧有效,但我很确定添加一个脚本元素应该。
(I believe all paths are relative to the root of the Air application itself.)
(我相信所有路径都与Air应用程序本身的根相对。)