title: SharePoint 2010 - Content Editor Web Part Duplicating Entries
body: <p>I'm using Javascript inside of a SharePoint 2010 Content Editor Web Part to insert a Silverlight object.  I need to do it this way instead of use a Silverlight Web Part because Silverlight Web Parts are not currently enabled. This is done entirely using Javascript.</p>
  
  <p>The problem occurs when I go later to edit the Javascript inside of the CEWP - I can see the orginal Javascript requesting generation of Silverlight object and I can, this is the strange part, the CEWP has all of the generated HTML of the Silverlight object right there appended to the scrept.</p>
  
  <p>So now, when I save, I save the script to generate the Silverlight object AND the HTML that was previously generated effectively duplicating the Silverlight object. If I edit again then I will now have three Silverlight objects and so on.</p>
  
  <p>You can see this in action for yourself with the following sample code:</p>
  
  <ol>
  <li>Add a new Content Editor Web Part to a page in SharePoint 2010</li>
  <li>Edit the source HTML</li>
  <li><p>Add the following code:</p>
  
  <p><code>&lt;script type="text/javascript"&gt;document.write("Hello&lt;br/&gt;");&lt;/script&gt;</code></p></li>
  </ol>
  
  <p>Save the web part and you're done.  Now, just keep editing the CEWP.  Every time you click "Edit Web Part", "Hello" will be appended to your script.</p>
  
  <p>How can I use Javascript to insert DOM elements and not have the generated HTML appear in the CEWP?</p>