Remove all client Script Javascipt,vbscript,jscript,js,event

Source: Internet
Author: User
Tags regular expression

Remove all client Script Javascipt,vbscript,jscript,js,vbs,event
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Remove all client script javascipt,vbscript,jscript,js,vbs,event</title>

<body>
<div id= ' Browser ' ></div>
<script language= "JavaScript Tutorial" >
function Decodefilter (HTML, filter) {
Switch (Filter.touppercase ()) {
Case "Script"://Remove all client script Javascipt,vbscript,jscript,js,vbs,event,...
html = execre ("</?script[^>]*>", "", HTML);
html = Execre ("(javascript|jscript|vbscript|vbs):", "$:", HTML);
html = Execre ("On" (Mouse|exit|error|click|key), "<I>on$1</I>", HTML);
html = execre ("&#", "<I>&#</I>", HTML);
Break
Case "class"://Remove Style class class= ""
html = Execre ("(<[^>]+) class=[^ |^>]* ([^>]*>)", "$ $", HTML);
Break
Case "style"://Remove style style= ""
html = Execre ("(<[^>]+) style=" [^ "]*" ([^>]*>) "," $ $ ", HTML);
Break
Case "XML"://removing XML
html = execre ("<\?xml[^>]*>", "", HTML);
Break
Case "NAMESPACE"://removal of namespaces <o:p></o:p>
html = execre ("</?[ A-z]+:[^>]*> "," ", HTML);
Break
Case "FONT"://Remove Font <font></font>
html = execre ("</?font[^>]*>", "", HTML);
Break
Case "MARQUEE"://Remove Subtitles <marquee></marquee>
html = execre ("</?marquee[^>]*>", "", HTML);
Break
Case "Object"://Remove Object <object><param><embed></object>
html = execre ("</?object[^>]*>", "", HTML);
html = execre ("</?param[^>]*>", "", HTML);
html = execre ("</?embed[^>]*>", "", HTML);
Break
Default
}
return HTML;
}

// ============================================
Perform regular expression substitution
// ============================================
function Execre (Re, RP, content) {
Oreg = new RegExp (Re, "IG");
R = Content.replace (Oreg, RP);
return R;
}
document.getElementById (' browser '). InnerHTML =br;
</script>

Site original tutorial, reprinted annotated source www.111cn.net
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.