I could use regex to get rid of the <script>
tags in the HTML like this
$html = preg_replace('#<script(.*?)>(.*?)</script>#is','', $html);
So that works fine, but what about inline JavaScript? I figured out I could do it this way
$nodes = $dom->getElementsByTagName('*');
foreach($nodes as $node)
{
if ($node->hasAttribute('onload')){
$node->removeAttribute('onload');
}
}
The issue with this is I'd have to find all the attributes, and keep making if
statements. I've also seen libraries, but I want to keep things small. So is there any quick way? Also any nice lists with inline attributes if I have to keep doing what I'm doing?