Jyxo\Html::removeJavascriptEvents PHP Method

removeJavascriptEvents() public static method

If it is necessary to remove only certain events, the removeAttributes() method can be used. Expects valid HTML source.
public static removeJavascriptEvents ( string $html ) : string
$html string HTML source code
return string
    public static function removeJavascriptEvents(string $html) : string
    {
        // A tag can have multiple events, therefore it is necessary to process the source multiple times
        while (preg_match('~<[a-z][a-z0-9]*[^>]*?\\s+on[a-z]+="[^"]*"~is', $html)) {
            $html = preg_replace('~(<[a-z][a-z0-9]*[^>]*?)\\s+on[a-z]+="[^"]*"~is', '\\1', $html);
        }
        return $html;
    }