title: Javascript: onclick/onsubmit for dynamically created button
body: <p>I dynamically create a button in the way I found in the Internet: </p>
  
  <pre><code> Page = function(...) {
     ...
   };
  
   Page.prototype = {
     ...
     addButton : function() {
       var b = content.document.createElement('button');
       b.onclick = function() { alert('OnClick'); }
     },
     ...
   };
  </code></pre>
  
  <p>Unfortunately, it's not working and throwing the following error:</p>
  
  <pre><code>  Error: [Exception... "Component is not available"  nsresult: "0x80040111
    (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: chrome://knowledgizer/content
    /knowledgizer.js :: &lt;TOP_LEVEL&gt; :: line 137"  data: no]
    Source File: chrome://browser/content/tabbrowser.xml Line: 434
  </code></pre>
  
  <p>The solution with setAttribute work:</p>
  
  <pre><code>b.setAttribute("onClick", "alert('OnClick')");
  </code></pre>
  
  <p>However, I want to call a class method (instead of alert), and the b.onclick syntax looks better in that respect, I hope/think. is this onclick case senstive? Because if I write</p>
  
  <pre><code>b.onClick = function() {alert("OnClick");} // notice the spelling onclick vs onClick
  </code></pre>
  
  <p>I don't get the error above, but it's still not working, i.e. I don't get the alert. I'm thankful for any tips.</p>
  
  <p>As a bonus question: How can I avoid that the current page is reload when the button is clicked? I just like call a method and not to cause a page reload.</p>
  
  <p>Thanks and best regards,</p>
  
  <p>Christian</p>