~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/modules/plugin/samples/simple/SimpleScriptableTest.html

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<HTML>
 
2
<H1> Simple XPConnect Scriptable Sample Plug-in </H1>
 
3
 
 
4
<p> 
 
5
 
 
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
 
9
from JavaScript.
 
10
 
 
11
<HR>
 
12
 
 
13
<center>
 
14
 
 
15
<EMBED type=application/x-simple name="simple1" width=400 height=300>
 
16
 
 
17
<script>
 
18
 
 
19
function GetText()
 
20
{
 
21
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
22
    
 
23
    document.the_form.the_text.value = 
 
24
        document.simple1.nsISimplePluginInstance.text;
 
25
}
 
26
 
 
27
function SetText()
 
28
{
 
29
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
30
    
 
31
    document.simple1.nsISimplePluginInstance.text = 
 
32
        document.the_form.the_text.value;
 
33
}
 
34
 
 
35
/*
 
36
// For JS evaluator below; unused.
 
37
 
 
38
var it = undefined; // persistent last special value.
 
39
function EvalIt() {
 
40
    var inText = document.eval_form.eval_text.value;
 
41
 
 
42
    dump(document.simple1);
 
43
 
 
44
    try {
 
45
        var result = eval(inText);
 
46
        result = result ? result : "";
 
47
        document.eval_form.result_text.value = result;
 
48
        if (it)
 
49
            document.eval_form.it_text.value = "it: " + it;
 
50
        document.eval_form.eval_text.value = "";
 
51
    } catch (err) {
 
52
        document.eval_form.result_text.value = "Exn: " + err.toString();
 
53
    }
 
54
    return true;
 
55
}
 
56
*/
 
57
</script>
 
58
 
 
59
 
 
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()'>
 
64
</form>
 
65
 
 
66
<!--
 
67
<hr>
 
68
<form name ="eval_form">
 
69
JavaScript evaluation for poking at the plugin ('document.simple1').<br>
 
70
input:<br>
 
71
<INPUT TYPE="text" NAME="eval_text" onchange = "EvalIt()" SIZE="80"><br>
 
72
result:<br>
 
73
<INPUT TYPE="text" NAME="result_text" SIZE="80"><br>
 
74
contents of 'it':<br>
 
75
<INPUT TYPE="text" NAME="it_text" SIZE="80">
 
76
<p>
 
77
<input type=button value="eval" onclick="EvalIt()">
 
78
</form>
 
79
-->
 
80
 
 
81
 
 
82
<hr>
 
83
 
 
84
</center>
 
85
 
 
86
<h4>Problems?</h4>
 
87
 
 
88
<ul>
 
89
 
 
90
<p><li><b>Can't load pluign</b>:
 
91
Copy the compiled plugin to your plugins directory 
 
92
 
 
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
 
96
directory.
 
97
 
 
98
<p><li><b>Plugin loads, but when I push the 'Set Text' button the plugin text 
 
99
is not updated</b>: 
 
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]
 
103
 
 
104
</ul>
 
105
 
 
106
<HR>
 
107
 
 
108
</HTML>