js将html转换为纯文本

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

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

原文地址:https://www.cnblogs.com/Neil223/p/6007739.html