Click to See Complete Forum and Search --> : Strip all javascript from HTML


keda
September 3rd, 2010, 04:13 AM
Does anyone happen to have a PHP script that can strip all javascript from HTML leaving the HTML tags, but removing the attributes for scripted events and script tags?

PeejAvery
September 3rd, 2010, 02:31 PM
1. Create an array of all JavaScript events (onclick, onkeypress, etc.).
2. Use preg_replace() to remove all contents inside.
3. Use preg_replace() to remove all <script> tags.
4. Use preg_replace() to remove all instances of "javascript:..."