title: replace() tag did not work in javascript
body: <p>I have database, that currently use inline edit in tables
  First problem was with paste of formatted text, but seems, that problem was fixed at 90% with this script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
                  var _onPaste_StripFormatting_IEPaste = false;
  
                  function OnPaste_StripFormatting(elem, e) {
  
                      if (e.originalEvent &amp;&amp; e.originalEvent.clipboardData &amp;&amp; e.originalEvent.clipboardData.getData) {
                          e.preventDefault();
                          var text = e.originalEvent.clipboardData.getData('text/plain');
                          window.document.execCommand('insertText', false, text);
                      }
                      else if (e.clipboardData &amp;&amp; e.clipboardData.getData) {
                          e.preventDefault();
                          var text = e.clipboardData.getData('text/plain');
                          window.document.execCommand('insertText', false, text);
                      }
                      else if (window.clipboardData &amp;&amp; window.clipboardData.getData) {
                          // Stop stack overflow
                          if (!_onPaste_StripFormatting_IEPaste) {
                              _onPaste_StripFormatting_IEPaste = true;
                              e.preventDefault();
                              window.document.execCommand('ms-pasteTextOnly', false);
                          }
                          _onPaste_StripFormatting_IEPaste = false;
                      }
  
                  }
  
      &lt;/script&gt;
  </code></pre>
  
  <p>My php code look like this:</p>
  
  <pre><code>&lt;td contenteditable='true' onblur=saveToDatabase(this,'titleeng','".$data['id']."') onClick='showEdit(this);' onpaste='OnPaste_StripFormatting(this, event);'&gt;".$data['titleeng']."&lt;/td&gt;
  </code></pre>
  
  <p>The script removes the tags, but leaves the <code>&amp;nbsp;</code> , that causing my sql ajax to failure</p>
  
  <p>Here is Ajax script:</p>
  
  <pre><code>&lt;script&gt;
          function showEdit(editableObj) {
              $(editableObj).css("background","#FFF");
          } 
  
          function saveToDatabase(editableObj,column,id) {
              $(editableObj).css("background","#12ff65 url(loaderIcon.gif) no-repeat right");
              $.ajax({
                  url: "saveedit.php",
                  type: "POST",
                  data:"column="+column+"&amp;editval="+editableObj.innerHTML+"&amp;id="+id,
                  success: function(data){
                      $(editableObj).css("background","#FDFDFD");
                  }        
             });
          }
          &lt;/script&gt;
  </code></pre>
  
  <p>I am trying this:
  New components are <code>text = text.replace("&amp;nbsp"," ");</code></p>
  
  <pre><code>var _onPaste_StripFormatting_IEPaste = false;
  
                  function OnPaste_StripFormatting(elem, e) {
  
                      if (e.originalEvent &amp;&amp; e.originalEvent.clipboardData &amp;&amp; e.originalEvent.clipboardData.getData) {
                          e.preventDefault();
                          var text = e.originalEvent.clipboardData.getData('text/plain');
                          string text = text;
                          text = text.replace("&amp;nbsp"," ");
                          window.document.execCommand('insertText', false, text);
                      }
                      else if (e.clipboardData &amp;&amp; e.clipboardData.getData) {
                          e.preventDefault();
                          var text = e.clipboardData.getData('text/plain');
                          string text = text;
                          text = text.replace("&amp;nbsp"," ");
                          window.document.execCommand('insertText', false, text);
                      }
                      else if (window.clipboardData &amp;&amp; window.clipboardData.getData) {
                          // Stop stack overflow
                          if (!_onPaste_StripFormatting_IEPaste) {
                              _onPaste_StripFormatting_IEPaste = true;
                              e.preventDefault();
                              window.document.execCommand('ms-pasteTextOnly', false);
                          }
                          _onPaste_StripFormatting_IEPaste = false;
                      }
  
                  }
  </code></pre>
  
  <p>But nothing</p>