首页 > 代码库 > sell -- js过滤敏感词

sell -- js过滤敏感词

1.

技术分享

2. code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
       window.onload = function () {
           var oFilterBtn = document.getElementById("btn");
           var aTxt = document.getElementsByTagName("textarea");
           var reg = /菲律宾|日本|日|菊花/g
           oFilterBtn.onclick = function () {
               var result = ‘‘;
               aTxt[1].value = http://www.mamicode.com/aTxt[0].value.replace(reg, function (str) {"*";
                   }
                   return result;
               });
           };
       };


    </script>
</head>
<body>
<textarea  cols="20" rows="10"></textarea><br>
<input id="btn" value="http://www.mamicode.com/filter sensitiveWords" type="button" ><br>
<textarea  cols="20" rows="10"></textarea>

</body>
</html>

 

sell -- js过滤敏感词