문제

I have the following XUL markup:

<?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>

I'm trying to get the JavaScript function sayHello() to work when the toolbarbutton logout is clicked however nothing occurs and no JavaScript errors occur as well.

Does anyone know how to get JavaScript working with XUL?

Thanks in advance!

도움이 되었습니까?

해결책

Try with oncommand="sayHello('hello')"

다른 팁

Two suggestions:

  • you should encapsulate the code in a CDATA block.
  • try script type "application/x-javascript" instead of "text/javascript".
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top