2
<H1> Simple XPConnect Scriptable Sample Plug-in </H1>
6
This sample plug-in demonstrates how to write a XPConnect-enabled plug-in. You
7
should see in the plug-in rectangle below with the text "Hello World". The text
8
box and buttons demostrate calling the scriptable xpcom interfaces of the plugin
15
<EMBED type=application/x-simple name="simple1" width=400 height=300>
21
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
23
document.the_form.the_text.value =
24
document.simple1.nsISimplePluginInstance.text;
29
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
31
document.simple1.nsISimplePluginInstance.text =
32
document.the_form.the_text.value;
36
// For JS evaluator below; unused.
38
var it = undefined; // persistent last special value.
40
var inText = document.eval_form.eval_text.value;
42
dump(document.simple1);
45
var result = eval(inText);
46
result = result ? result : "";
47
document.eval_form.result_text.value = result;
49
document.eval_form.it_text.value = "it: " + it;
50
document.eval_form.eval_text.value = "";
52
document.eval_form.result_text.value = "Exn: " + err.toString();
60
<form name ="the_form">
61
<INPUT TYPE="text" NAME="the_text" VALUE="some text" SIZE="25">
62
<input type=button value="Set Text" onclick='SetText()'>
63
<input type=button value="Get Text" onclick='GetText()'>
68
<form name ="eval_form">
69
JavaScript evaluation for poking at the plugin ('document.simple1').<br>
71
<INPUT TYPE="text" NAME="eval_text" onchange = "EvalIt()" SIZE="80"><br>
73
<INPUT TYPE="text" NAME="result_text" SIZE="80"><br>
75
<INPUT TYPE="text" NAME="it_text" SIZE="80">
77
<input type=button value="eval" onclick="EvalIt()">
90
<p><li><b>Can't load pluign</b>:
91
Copy the compiled plugin to your plugins directory
93
<p><li><b>JavaScript error in the JavaScript console talking about how
94
XPConnect can't build a wrapper</b>:
95
Copy the type library (nsISimplePluginInstance.xpt) to the mozilla components
98
<p><li><b>Plugin loads, but when I push the 'Set Text' button the plugin text
100
Are you not running Windows? Only the Windows version updates text the plugin
101
draws. But the calls from JS to the plugin should work on all platforms.
102
[We welcome fixes to the samples if you'd like to submit them]