简体   繁体   English

您如何通过Firebreath在XUL内调用javascript?

[英]How do you call javascript inside of XUL through Firebreath?

I have written some javascript for my firefox extension in the XUL. 我已经在XUL中为我的firefox扩展编写了一些JavaScript。 This overlay has some cleanup functionality and I would like to be able to call the function through my NPAPI dll created via Firebreath. 此覆盖图具有一些清除功能,我希望能够通过Firebreath创建的NPAPI dll调用该功能。

I know that Firebreath has an example calling the "alert" function by doing the following: 我知道Firebreath有一个通过执行以下操作来调用“警报”功能的示例:

// Retrieve a reference to the DOM Window
    FB::DOM::WindowPtr window = m_host->getDOMWindow();

    // Check if the DOM Window has an alert peroperty
    if (window && window->getJSObject()->HasProperty("window")) {
        // Create a reference to alert
        FB::JSObjectPtr obj = window->getProperty<FB::JSObjectPtr>("window");

        // Invoke alert with some text
        obj->Invoke("alert", FB::variant_list_of("This is a test alert invoked from an NPAPI Plugin"));
    }

The above code works so I've modified the Invoke to call my javascript function. 上面的代码有效,因此我修改了Invoke来调用我的javascript函数。

obj->Invoke("cleanupCode", FB::variant_list_of("0"));

This does not work and is confusing me on how I should be calling my javascript function. 这不起作用,使我在如何调用javascript函数时感到困惑。

How does your DOM look out ? 您的DOM外观如何? Does window contain function named cleanupCode ? 窗口是否包含名为cleanupCode的函数? Maybe you can check it with firebug. 也许您可以使用萤火虫检查它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM