title: JavaScript onKeyPress assigning problem
body: <p>I am trying to add an onKeyPress event to a dynamically created html element using javascript. In practise, the element is added, the id is assigned, and the innerHTML added, but the onmouseover, onmouseout, and onKeyPress (2nd last line) events are not added to the element. The last line (.focus()) does work. </p>
  
  <p>Code:</p>
  
  <pre><code>function newParagraphAfter(elem)
  {
  blockElemId++;
  newPara = document.createElement("p");
  newPara.id = 'block_' + blockElemId;
  newPara.contentEditable = 'true';
  newPara.onmouseover = "this.style.border='1px dashed white';";
  newPara.onmouseout = "this.style.border='none';";
  newPara.innerHTML = "Edit Here!";
  elem.parentNode.insertBefore(newPara, elem.nextSibling);
  document.getElementById('block_' + blockElemId).onKeyPress = "return editKeypress(this, event)";
  document.getElementById('block_' + blockElemId).focus();
  }
  </code></pre>
  
  <p>Any help greatly appreciated,</p>
  
  <p>Nico</p>