title: I want to createElement with click event but there is a problem
body: <p>I need help for something in javascript.</p>
  
  <p>The idea is I want to make new element by using createElement method and I want to add onclick property to this new element and I want if click on this element Implement function.</p>
  
  <p>The code that I typed is as follows:</p>
  
  <h3>HTML</h3>
  
  <pre><code>&lt;a href="javascript:popupWin.crWindow()"&gt;open&lt;/a&gt;
  </code></pre>
  
  <h3>Javascript</h3>
  
  <pre><code>var popupWin = {
                  width: 640,
                  height: 480,
                  bg_colorBack: '#808080',
                  content: "&lt;div style='margin:0 auto; text-align:center; width:640px; heihgt:480px; background-color:rgba(255,255,255,1.0); color:#000;'&gt; Hello Wrold! &lt;/div&gt;",
  
                  crWindow: function(){
                      var winElem = document.createElement('div');
                      winElem.id = 'flywin';
                      winElem.style.backgroundColor = this.bg_colorBack;
                      winElem.style.direction = 'rtl';
                      winElem.style.textAlign = 'center';
                      winElem.style.width = '100%';
                      winElem.style.height = '100%';
                      winElem.style.position = 'absolute';
                      winElem.style.top = '0';
                      winElem.style.left = '0';
                      winElem.style.opacity = '0.6';
                      winElem.style.filter = 'alpha(opacity=60)';
                      winElem.innerHTML = this.content;
                  winElem.onclick = this.closeWindow();
                      document.body.appendChild(winElem);
                  },
  
                  closeWindow: function(){
                      alert('hello');
                  }
              }
  </code></pre>