type
attribute of the script
element defines the MIME type of the script. type
attribute is not defined, and the script is embedded, the script will be assumed to be a Javascript scripttype
attribute is not defined, and the script is external the script will be inferred from the file extensionscript
element: <script> function clicked(){ alert('Hello World!'); } </script>or:
<script type="application/groovy"> public int getValue(){ return 10; } </script>
<script src="myScript.js" />
oncommand
, onclick
, or onchange
) must refer to a function or method defined for a script associated with the XUL script[1]
<window title="Hello" orient="horizontal" width="250" height="100" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script> function clicked() { alert('Hello World!'); } </script> <button label="Push Me!" oncommand="clicked()" /> </window>
true
, this XUL script is valid: <window title="Hello" orient="horizontal" width="250" height="100" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="text/groovy" > public int clicked() { context.echo("Hello World!"); } </script> <button label="Push Me!" oncommand="clicked()" /> </window>
getCurrentDocument()
and getCurrentWidget()
on the helper will return the XUL document or widget from which originates the last event. getCurrentDocument()
methodgetCurrentWidget()
methodcontext
field in your script. For example: public void clicked() { context.echo("Hello World"); }The script helper is available through the
helper
field in your script. For example: public void clicked() { XULWidget widget helper.getCurrentWidget(); }
Copyright 2008-2020 Herve Girod. All Rights Reserved. Documentation and source under the LGPL licence