Firefox中的Ajax添加面板内容JavaScript

Ajax in Firefox add on panel content JavaScript

本文关键字:JavaScript 中的 Ajax 添加 Firefox      更新时间:2023-09-26

我在SDK上使用Firefox插件。我在工具栏上有按钮,在点击事件中我显示面板html文件。现在我需要在面板html文件中使用的html按钮的点击中使用ajax功能。


    <html>
    <script>
    function test()
    {
    var xhr=new XMLHttpRequest();
    //some ajax Code 
    }
    </script>
    <button onclick='test()'>click Here</button>
    </html>

我是Firefox SDK的新手。有可能吗??如果可能的话,我该怎么做?

您不能在Firefox插件的html页面中使用内联脚本,将脚本作为打包的本地资源添加,它就会被执行。

基本上,您必须将HTML和JS一分为二,并在HTML 中引用JS