[英]JavaScript not executing inside xul file
I am having trouble writing js in a XUL file. 我在XUL文件中编写js时遇到问题。 I have written a simple method inside xul but it doesn't execute when you open the browser.
我在xul内编写了一个简单的方法,但是当您打开浏览器时它不会执行。
This is the method inside the xul tag: 这是xul标记内的方法:
function demo() {
alert('hello');
}
I ve tried to change the tag of the script from <script>
to <html:script>
but still method doesn't work. 我试图将脚本的标签从
<script>
更改为<html:script>
但方法仍然无效。 I tried to use methods from external js file using <html:script type="application/x-javascript" src="overlay.js">
still not working. 我尝试使用
<html:script type="application/x-javascript" src="overlay.js">
仍然无法正常使用外部js文件中的方法。
The name of the xul file is ff-sidebar.xul
. xul文件的名称是
ff-sidebar.xul
。 Basically what I am trying to do is display text on the sidebar using javascript functions that are in external js files. 基本上我想做的是使用外部js文件中的javascript函数在边栏上显示文本。 I really need javascript to work inside xul file so I can use the js methods.
我真的需要javascript才能在xul文件中工作,以便可以使用js方法。 I know for sure that nothing is wrong with the js file.
我肯定知道js文件没有问题。
I think you have an addressing problem in your JavaScript reference. 我认为您在JavaScript参考中有一个解决的问题。 I believe Firefox is not able to locate overlay.js.
我相信Firefox无法找到overlay.js。 Try this:
尝试这个:
<script type="application/javascript" src="chrome://sidebar/content/overlay.js">
where "sidebar" is the name of your app, and your .js file is located in the "sidebar/chrome/content" directory, alongside your sidebar.xul file. 其中“ sidebar”是应用程序的名称,.js文件位于sidebar.xul文件旁边的“ sidebar / chrome / content”目录中。
More information on the chrome URL can be found here . 有关chrome URL的更多信息,请参见此处 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.