Making a string safe by removing all javascript codes and events
<p>I want to remove all javascript codes from a string that contains html code.</p>

<p>For example these are some unwanted javascript codes that may cause problems on your website: </p>

<pre><code>&lt;div onmouseover='window.location = "http://To-Undesirable-Location"'&gt;&lt;/div&gt;
</code></pre>

<p>or</p>

<pre><code>&lt;img onload='window.location = "http://To-Undesirable-Location"'&gt;&lt;/img&gt;
</code></pre>

<p>or </p>

<pre><code>&lt;script language="javascript&gt; ...unwanted code... &lt;/script&gt;
</code></pre>

<p><em>Since hackers can use this js functions to redirect your page to some unwanted pages I wonder why there are not some good source to make this type of content safe... On any website there are usually a simple WYSIWYG editor that users can put their html content inside it.</em></p>

<p>Thanks</p>
