FireFox plug-in and extended development (1) -- npruntime instance

Source: Internet
Author: User

I plan to compile a Firefox plug-in. First, let's take a look at the examples provided on the official website.

 

: Http://mxr.mozilla.org/seamonkey/source/modules/plugin/samples/npruntime/

Download Method: I tried SVN, but I had to manually click each file in the project. A box is displayed in the upper right corner of the page, including CVS Log, CVS Blame, CVS Graph, diff file, Raw file. Select Raw file and save it

 

Compile the project as instructed on the web page: https://developer.mozilla.org/en/Compiling_The_npruntime_Sample_Plugin_in_Visual_Studio

If an error occurs after compilation, check the Version Issues at the bottom of the page.

 

After the compilation is successful, I will make some modifications, because test.htm In the example is too old.

 

Modify the Invoke function in plugin. cpp to block the code in the original function.

Bool <br/> ScriptablePluginObject: Invoke (NPIdentifier name, const NPVariant * args, <br/> uint32_t argCount, NPVariant * result) <br/>{< br/> if (name = sFoo_id) {<br/> printf ("foo called! /N "); <br/> MessageBox (NULL, L" foo called ", L" Promopt ", MB_ OK); <br/> return PR_TRUE; <br/>}< br/> return PR_FALSE; <br/>}< br/>

Modify the Invoke function to the pop-up dialog box.

 

Modify the test.htm file

<HTML> <br/> <pead> <br/> <title> Scriptable plug-in test </title> <br/> </pead> <br/> <body id = "bodyid"> <br/> <center> <br/> <p> sample Scriptable plug-in </p> <br/> </center> <br/> <br/> <center> <br/> <Div id = "result"> <br/> <p> results go here: </P> <br/> </div> <br/> <embed id = "embed1" name = "mypi" type = "application/Mozilla-npruntime-Scriptable-plugin "width = 600 Height = 40> <br/> <MCE: script Type =" Text/JavaScript "> <! -- <Br/> var embed1 = document. getelementbyid ('embedded 1'); <br/> // --> </MCE: SCRIPT> <br/> <form name = "formname"> <br/> <input type = button value = "alert (embed1.foo ()" onclick = 'embed1. foo () '> <br/> <input type = button value = "Call pluginobj. foo () "onclick = 'ininobj. foo () '> <br/> <input type = button value = "alert (mypi. foo () "onclick = 'document. mypi. foo () '> <br/> <input type = button value = "alert (pluginobj. bar) "onclick = 'alert (pluginobj. bar) '> <br/> </form> <br/> </center> <br/> </body> <br/> </ptml>

There are three methods in this example to obtain the plug-in and then call the foo function. A dialog box is displayed. The last button is used to obtain the property value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.