js将html转换为纯文本

  1. document.body.textContent//firefox浏览器  
  2.   
  3.   
  4. document.body.innerText//适用ie webkit浏览器   
  5.   
  6. document.body.innerHTML.replace(/<(style|script|iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi,'').replace(/<[^>]+?>/g,'').replace(/\s+/g,' ').replace(/ /g,' ').replace(/>/g,' ');  

转自:http://blog.csdn.net/zhhaogen/article/details/7370052

posted @ 2016-10-28 14:34  小六.223  阅读(1159)  评论(0编辑  收藏  举报