如何在我的firebreath插件中启动javascript函数 [英] how to start the javascript function in my firebreath plugin

查看:229
本文介绍了如何在我的firebreath插件中启动javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在firebreath插件文件'MyPluginProject.cpp'中实现了一个javascript函数

I have implemented a javascript function in firebreath plugin file 'MyPluginProject.cpp'

void MyPluginProjectAPI::MyJsThings()
{
    std::string argument = "my javascript functionality goes here";

    m_host->evaluateJavaScript(argument);
}



现在要在我的网页中使用MyJsThings插件。
现在我可以调用MyJsThings通过调用它在我的javascript代码如下

Now to use the MyJsThings in my webpages I have created <object> for the plugin. Now I can call MyJsThings by calling it in my javascript code like below

plugin.MyJsThings()

这是最基本的东西。
现在我不想在我的javascript中调用MyJsThings方法。我只是通过下面的代码为插件创建对象。

This is the very basic thing. Now I don't want to call MyJsThings method in my javascript. I am just creating object for the plugin by below code.


<object type="application/x-my-plugin-project" id="plugin" style="width:0px;height:0px;">
        <param id="onload" value="alert('Plugin Loaded');"> 
</object>

当我加载我的页面时,我想要调用MyJsFunction方法,这样我的js功能将会完成剩下的工作。 br />
我的主要目的是在插件加载时调用函数MyJsFunction,而不是在html脚本中的任何位置。

When I load my page I want my method MyJsFunction has to be called so that my js functionalities will do the remaining things.
My main aim is to call the function MyJsFunction when the plugin is loaded, not in any where in the html script.

推荐答案

听起来像你真正想要的是在PluginCore派生对象中使用onPluginLoad方法。

Sounds like what you really want is to use the onPluginLoad method in your PluginCore-derived object.

请注意, d阅读网站上的入门页面和/或浏览FBTestPlugin示例 - 强烈推荐阅读。

Note that you would have found this if you'd read the getting started pages on the website and/or looked through the FBTestPlugin example -- highly recommended reading.

这篇关于如何在我的firebreath插件中启动javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆