Pregunta
Tengo el siguiente marcado XUL:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window width="400" height="275" title="Placeholder"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:pen="http://www.pentaho.org/2008/xul" onload="mainToolbarHandler.init()">
<script type="text/javascript">
function sayHello(txt) {
alert(txt);
}
</script>
<toolbar id="mainToolbar">
<toolbarbutton id="logout" image="mantle/images/new_report_32.png" onclick="sayHello('hello')" tooltiptext="Logout"/>
</toolbar>
</window>
Estoy tratando de obtener la función de JavaScript sayHello () para el trabajo cuando se hace clic en el cierre de sesión ToolBarButton sin embargo nada ocurre y no hay errores de JavaScript ocurrir también.
¿Alguien sabe cómo conseguir JavaScript trabajar con XUL?
Gracias de antemano!
Solución
Trate con oncommand="sayHello('hello')"
Otros consejos
Dos sugerencias:
- debe encapsular el código en un bloque de noreferrer"> href="https://developer.mozilla.org/en/Writing_JavaScript_for_XHTML#Solution.3a_The_CDATA_Trick" rel="nofollow .
- intento script type "application / x-javascript" en lugar de "text / javascript".
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow