美文网首页
敏感字符过滤

敏感字符过滤

作者: 羊绘霖 | 来源:发表于2017-11-01 15:47 被阅读0次

    //敏感字符过滤

    export var filterWord = {

    handle:function(val) {

    // var str = this.loadXML('/test.xml')

    var str =this.loadXML('/static/js/sensitive.txt')

    var reBadWords =newRegExp(str,"ig");

    // debugger

    return val.replace(reBadWords,"**");

    },

    loadXML:function(xmlFile) {

    // this.loadXML('http://192.168.0.39:8005/static/js/test.xml')

    // xmlDoc.getElementsByTagName("row")[0].children[0].innerHTML

    var xmlhttp,xmlDoc;

    if(window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari

    xmlhttp =newXMLHttpRequest();

    }

    else{// code for IE6, IE5

    xmlhttp =new ActiveXObject("Microsoft.XMLHTTP");

    }

    xmlhttp.open("GET",xmlFile,false);

    xmlhttp.send();

    var str;

    var arr = xmlhttp.responseText;

    for(var i =0;i < arr.length;i++) {

    str +="|"+ arr[i]

    }

    return str;

    // xmlDoc = xmlhttp.responseXML;

    // var str, node = xmlDoc.getElementsByTagName("row");

    // for (var i = 0; i < node.length; i++) {

    //    str += "|" + node[i].children[0].innerHTML

    // }

    // return str.substr(1)

    }

    };

    相关文章

      网友评论

          本文标题:敏感字符过滤

          本文链接:https://www.haomeiwen.com/subject/ztrgpxtx.html