RetroZilla/modules/plugin/samples/simple/SimpleScriptableTest.html
2015-10-20 23:03:22 -04:00

109 lines
2.6 KiB
HTML

<HTML>
<H1> Simple XPConnect Scriptable Sample Plug-in </H1>
<p>
This sample plug-in demonstrates how to write a XPConnect-enabled plug-in. You
should see in the plug-in rectangle below with the text "Hello World". The text
box and buttons demostrate calling the scriptable xpcom interfaces of the plugin
from JavaScript.
<HR>
<center>
<EMBED type=application/x-simple name="simple1" width=400 height=300>
<script>
function GetText()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
document.the_form.the_text.value =
document.simple1.nsISimplePluginInstance.text;
}
function SetText()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
document.simple1.nsISimplePluginInstance.text =
document.the_form.the_text.value;
}
/*
// For JS evaluator below; unused.
var it = undefined; // persistent last special value.
function EvalIt() {
var inText = document.eval_form.eval_text.value;
dump(document.simple1);
try {
var result = eval(inText);
result = result ? result : "";
document.eval_form.result_text.value = result;
if (it)
document.eval_form.it_text.value = "it: " + it;
document.eval_form.eval_text.value = "";
} catch (err) {
document.eval_form.result_text.value = "Exn: " + err.toString();
}
return true;
}
*/
</script>
<form name ="the_form">
<INPUT TYPE="text" NAME="the_text" VALUE="some text" SIZE="25">
<input type=button value="Set Text" onclick='SetText()'>
<input type=button value="Get Text" onclick='GetText()'>
</form>
<!--
<hr>
<form name ="eval_form">
JavaScript evaluation for poking at the plugin ('document.simple1').<br>
input:<br>
<INPUT TYPE="text" NAME="eval_text" onchange = "EvalIt()" SIZE="80"><br>
result:<br>
<INPUT TYPE="text" NAME="result_text" SIZE="80"><br>
contents of 'it':<br>
<INPUT TYPE="text" NAME="it_text" SIZE="80">
<p>
<input type=button value="eval" onclick="EvalIt()">
</form>
-->
<hr>
</center>
<h4>Problems?</h4>
<ul>
<p><li><b>Can't load pluign</b>:
Copy the compiled plugin to your plugins directory
<p><li><b>JavaScript error in the Error console talking about how
XPConnect can't build a wrapper</b>:
Copy the type library (nsISimplePluginInstance.xpt) to the mozilla components
directory.
<p><li><b>Plugin loads, but when I push the 'Set Text' button the plugin text
is not updated</b>:
Are you not running Windows? Only the Windows version updates text the plugin
draws. But the calls from JS to the plugin should work on all platforms.
[We welcome fixes to the samples if you'd like to submit them]
</ul>
<HR>
</HTML>