Question
Je le balisage XUL suivant:
<?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>
Je suis en train de se rendre au travail lorsque l'on clique sur toolbarbutton mais la déconnexion se produit et ne pas d'erreur JavaScript se produit aussi bien la fonction JavaScript sayHello ().
Quelqu'un sait comment obtenir JavaScript travailler avec XUL?
Merci d'avance!
La solution
Essayez avec oncommand="sayHello('hello')"
Autres conseils
Deux suggestions:
- vous devez encapsuler le code dans un bloc CDATA .
- "application / x-javascript" essayer type de script au lieu de "text / javascript".
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow