string 转 html js textarea text 转div

   String.prototype.replaceAll = function(s1,s2){ 
return this.replace(new RegExp(s1,"gm"),s2); 

var textTohtml = function( $str ){

    return $str.replaceAll("&", "&")
    .replaceAll("<", "<")
    .replaceAll(">", ">")
    .replaceAll(String.fromCharCode(32), " ")
    .replaceAll(String.fromCharCode(9), " ")
    .replaceAll(String.fromCharCode(9), "    ")
    .replaceAll(String.fromCharCode(34),  """)
    .replaceAll(String.fromCharCode(39),  "'")
    .replaceAll(String.fromCharCode(13),  "")
    .replaceAll(String.fromCharCode(10),  "
")
    }

你可能感兴趣的:(string 转 html js textarea text 转div)