Strip Script from HTML code - Node.js String

Node.js examples for String:Strip

Description

Strip Script from HTML code

Demo Code


stripScript: function(html) {
    // script blocks
    html = html.replace(/<[^>]*script[^>]*>/gi, "");
    // node events
    html = html.replace(/<[^>]*[\s]on[^>]*>/gi, "");
    // other horrid things
    html = html.replace(/<[^>]*object[^>]*>/gi, "");
    html = html.replace(/<[^>]*embed[^>]*>/gi, "");
    html = html.replace(/<[^>]*iframe[^>]*>/gi, "");
    return html;/*  w w  w .  j  a  v  a  2 s. c o  m*/
},

Related Tutorials