没错,就是这样一个需求;我现在有页面源文件的HTML字符串,
但是我需要去除里面的JS脚本,
当然也要同时去除标签中JS的调用哪位有实现的经验和思路可共享下,急急急!!!!~在线等...

解决方案 »

  1.   


    我就是用的正则表达式去的JS脚本
    关键就是调用那块儿  实在是头痛啊
    不过还是谢谢  KK3K2005
      

  2.   

    顺便问一下,我用正则表达式去除JS脚本
    下面的代码有问题吗?System.Text.RegularExpressions.Regex.Replace(htmlStr, @"<script[^>]*?>.*?</script>", "",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
      

  3.   

    为什么这个问题没人关注呢?自己再顶下去除JS脚本已经实现了关键是去除页面中对JS的调用我现在是通过JQuery的笨方法实现的如:
    $("#div_Preview_Content *").each(function () {
                $(this).removeAttr("onblur");
                $(this).removeAttr("onclick");
                $(this).removeAttr("ondblclick");
                $(this).removeAttr("onfocus");
                $(this).removeAttr("onkeydown");
                $(this).removeAttr("onkeypress");
                $(this).removeAttr("onkeyup");
                $(this).removeAttr("onmousedown");
                $(this).removeAttr("onmouseout");
                $(this).removeAttr("onmousemove");
                $(this).removeAttr("onmouseover");
                $(this).removeAttr("onmouseup");
            });但是这样的实现方式,性能明显达不到要求谁能提供更好的实现或思路吗?