代码描述:js清除复制黏贴 文本格式。js清除复制黏贴文本格式代码下载
当从word或者其他的网页赋值黏贴文本内容的时候,往往也会将连带的格式也会复制过来,但是这往往并非我们想要的东西,当然在编辑器中通常都有清除格式的功能,下面还是介绍一下如何使用javascript清除那些格式。 代码如下:
<script> cleanWord = function(){ var editBody = FCKeditorAPI.GetInstance("text").EditorDocument.body; var html = FCKeditorAPI.GetInstance("text").EditorDocument.body.innerText; for(var intLoop=0;intLoop<editBody.all.length;intLoop++){ el=editBody.all[intLoop]; el.removeAttribute("className","",0); el.removeAttribute("style","",0); el.removeAttribute("font"," ",0); } html=html.replace(/<o:p> <\\/o:p>/g,""); html=html.replace(/o:/g,""); html=html.replace(/<font>/g,""); html=html.replace(/<FONT>/g,""); html=html.replace(/<span>/g,""); html=html.replace(/<SPAN>/g,""); html=html.replace(/<SPANlang=EN-US>/g,""); html=html.replace(/<P>/g,""); html=html.replace(/<\\/P>/g,""); html=html.replace(/<\\/SPAN>/g,""); FCKeditorAPI.GetInstance("text").EditorDocument.body.innerText=html; } </script>
请绑定手机号,在继续操作
注意:只有绑定手机以后,才可使用网站全部功能