΢ Ͷ ^ ھ

cba直播赛程 :js̎W퓾݋DxȥDxȥHTML˺t

cba㶫 www.axwwg.com  •rg2020-02-26 19:43:04   ߣ   ҪuՓ(0)

ı݋ɵHTML˺MDxȻ딵ֹ_ע룺


function htmlEncode(value){
return $('<div/>').text(value).html();
}

1Ĕ

ı݋ɵHTML˺MDxȻ딵ֹ_ע룺

function htmlEncode(value){
return $('<div/>').text(value).html();
}

1ĔóDxHTML˺ȵȥDxȻȥHTML˺ɿs

/*ƳHTML˺a*/
 function removeHTMLTag(str) {
   str = str.replace(/<\/?[^>]*>/g,''); //ȥHTML tag
   str = str.replace(/[ | ]*\n/g,'\n'); //ȥβհ
   //str = str.replace(/\n[\s| | ]*\r/g,'\n'); //ȥ
   str=str.replace(/ /ig,'');//ȥ 
   return str;
 }
 //DQַͨ
 function escape2Html(str) { 
  var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'}; 
  return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];}); 
 } 

Ԕ퓵ԒֱȥDxͿ@ʾˣ

 //DQַͨ
 function escape2Html(str) { 
  var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'}; 
  return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];}); 
 } 

2JSt^Vȥı݋еFONT-SIZE˺

var test=test.replace(/font-size:\w+;?/g,'');

3js̎ȥı݋htmlʽֻ@ʾփԹбʹ

<script type="text/javascript">
var description = '<p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.1pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <b><span lang="EN-US" style="font-family:w;mso-bidi-font-family:w;color:#252525">1.</span></b><b><span style="font-family:w;mso-bidi-font-family:w;color:#252525">HUoИI<span lang="EN-US"><o:p></o:p></span></span></b></p> <p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <span lang="EN-US" style="font-family:w;mso-bidi-font-family:w;color:#252525">2010</span><span style="font-family:w;mso-bidi-font-family:w;color:#252525">ȫUoИIЈҎģ<span lang="EN-US">437.56</span>|Ԫ<span lang="EN-US">2015</span>L<span lang="EN-US">581.3</span>|Ԫ<span lang="EN-US"><o:p></o:p></span></span></p> <p align="center" style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt; margin-left:0cm;text-align:center;mso-pagination:widow-orphan"> <span lang="EN-US" style="font-family:w;mso-bidi-font-family:w;color:#252525">2010-2015</span><span style="font-family:w;mso-bidi-font-family:w;color:#252525">HUoИIЈҎģ|Ԫ</span></p> <p style="margin: 19.5pt 0cm; text-indent: 24.1pt; text-align: center;"> <img alt="" src="/baoxian/userfiles/1/images/back/news/2018/01/11.png" style="width: 493px; height: 296px;" /></p> <p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.1pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <b><span lang="EN-US" style="font-family:w;mso-bidi-font-family:w;color:#252525">2.</span></b><b><span style="font-family:w;mso-bidi-font-family:w;color:#252525">HUoИIُ<span lang="EN-US"><o:p></o:p></span></span></b></p> <p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <span style="font-family:w;mso-bidi-font-family:w;color:#252525">Uo˾ُ^l<span lang="EN-US">2011</span>겢ُ<span lang="EN-US">351</span>ҳʬFLڅһɱUИIIJُLϯȫЈͶYF<span lang="EN-US">Exor</span>ُٱU˾<span lang="EN-US">PartnerRe</span>w?Τ?fRcUo˾<span lang="EN-US">GrasSavoye</span>ʿUF<span lang="EN-US">ACE</span>ُ<span lang="EN-US">Chubb</span>ԼU˾<span lang="EN-US">Anthem</span>ُ<span lang="EN-US">Cigna</span>@Щ^ǽUIُεһС<span lang="EN-US"><o:p></o:p></span></span></p> <p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <span style="font-family:w;mso-bidi-font-family:w;color:#252525">Ȼڟ[̵IJُϢsLJĬFʿDԃ<span lang="EN-US">BCG</span><span lang="EN-US">1990</span><span lang="EN-US">2014</span>g<span lang="EN-US">778</span>漰UIIJُM˷ُһȵĹɖ|؈M׷ۙKlFֻ<span lang="EN-US">51%</span>IJُ܌Hrֵ<span lang="EN-US">49%</span>IJُtݚ˹˾ărֵ딵ُʧɚw̞ԭ򣺲ُʂُ͈ԼُrC<span lang="EN-US"><o:p></o:p></span></span></p> <p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.1pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <b><span lang="EN-US" style="font-family:w;mso-bidi-font-family:w;color:#252525">3.</span></b><b><span style="font-family:w;mso-bidi-font-family:w;color:#252525">UIm<span lang="EN-US"><o:p></o:p></span></span></b></p> <p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <span style="font-family:w;mso-bidi-font-family:w;color:#252525">δ<span lang="EN-US">5</span>^،^mƄӱUIMDZO^mվonjYʵҪ^moՓǪU߀ǾCϼFеYʺͶY؈^m^ˮƽڳ??ʹyĉUIӯܵ<span lang="EN-US"><o:p></o:p></span></span></p> <p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <span style="font-family:w;mso-bidi-font-family:w;color:#252525">dֵ{ҲСUBiкŹ˾пUИIărֵ@ЩIЃrֵBǵMߔғc֮͑gġһBµ\IģʽyUIyƿlrֵ׳ɞ̘IģʽĿһЩWjۺaƷ܉Mṩr͸ĮaƷ<span lang="EN-US"><o:p></o:p></span></span></p> <p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <span style="font-family:w;mso-bidi-font-family:w;color:#252525">YԣĴͱU˾ͶYŽ{Щֻ۽ڃȲ\Iⲿ׃ҕҊIRҵĸڱU˾f˽MߵОPҪȻOĴ󔵓gĻ͈Fꠎijɱ޴׌Ҏģ^СıU˾yԳڱUIfЙCLęCdzЈѽM뵽ڃMdЈlչCЈhdzsҪЈγҎģЧُ@ȻǸUI֮x<span lang="EN-US"><o:p></o:p></span></span></p> <p align="center" style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt; margin-left:0cm;text-align:center;mso-pagination:widow-orphan"> <span style="font-family:w;mso-bidi-font-family:w;color:#252525">ǰʮUo˾HIռ<span lang="EN-US"><o:p></o:p></span></span></p> <p align="center" style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt; margin-left:0cm;text-align:center;mso-pagination:widow-orphan"> <img alt="" src="/baoxian/userfiles/1/images/back/news/2018/01/12.png" style="width: 554px; height: 289px;" /></p> <p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.1pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <b><span lang="EN-US" style="font-family:w;mso-bidi-font-family:w;color:#252525">4.</span></b><b><span style="font-family:w;mso-bidi-font-family:w;color:#252525">HUoИIˮƽ<span lang="EN-US"><o:p></o:p></span></span></b></p> <p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> <span style="font-family:w;mso-bidi-font-family:w;color:#252525">Ŀǰ<span lang="EN-US">2015</span>ȫUoИI_<span lang="EN-US">581.3</span>|ԪHUoИIˮƽS<span lang="EN-US">10~25%</span>֮g<span lang="EN-US"><o:p></o:p></span></span></p>';
description = description.replace(/(\n)/g, ""); 
description = description.replace(/(\t)/g, ""); 
description = description.replace(/(\r)/g, ""); 
description = description.replace(/<\/?[^>]*>/g, ""); 
description = description.replace(/\s*/g, "");
console.log(description) 
</script>

4jQuery JavaScriptt_ʽc\n<BR>

Lee TaylorTeneffoԓ}̎ʽ

var str = document.getElementById('mydiv').innerHTML;
document.getElementById('mytextarea').innerHTML = str.replace(/<br\s*[\/]?>/gi, "\n");

or using jQuery:

var str = $("#mydiv").html();
var regex = /<br\s*[\/]?>/gi;
$("#mydiv").html(str.replace(regex, "\n"));

5Ҫȥhtml˺DƬQ܇

description = description.replace(/(\n)/g, "");
description = description.replace(/(\t)/g, "");
description = description.replace(/(\r)/g, "");
description = description.replace(/<\/?[^>]*>/g, "");
description = description.replace(/\s*/g, "");

6_֮СһQfackeditorеĶbrcе

//ӏQҪǿ]brĆ}
function doRepAdvance(s){
var str=s.replace(/<p><br type="_moz"><\/p>/ig,"");
str=str.replace(/<br type="_moz">\n <\/p>/ig, "</p>");
str=str.replace(/<br type="_moz">\n<\/p>/ig, "</p>");
str=str.replace(/<br type="_moz">\n\r<\/p>/ig, "</p>");
str=str.replace(/<br type="_moz"><\/p>/ig,"</p>");
str=str.replace(/<br \/>\n <\/p>/ig, "</p>");
str=str.replace(/<br>\n <\/p>/ig, "</p>");
str=str.replace(/<br \/>\n<\/p>/ig, "</p>");
str=str.replace(/<br \/>\n\r<\/p>/ig, "</p>");
str=str.replace(/(<br>\n){1,}<\/p>/ig,"</p>");
str=str.replace(/(<br>){1,}<\/p>/ig,"</p>");
str=str.replace(/<br>\n<\/p>/ig, "</p>");
str=str.replace(/<br><\/p>/ig,"</p>");
str=str.replace(/<p> <\/p>/ig,"");
str=str.replace(/<p> <\/p>/ig,"");
str=str.replace(/<p> <\/p>/ig,"");
str=str.replace(/<p><\/p>/ig,"");
return str;
}

@ƪPjs̎ı݋DxȥDxȥHTML˺t¾ͽB@,P݋DxȥDxȥHTML˺Ո_֮ǰ»PϣԺ֧_֮

ܸdȤ:

  • jsȥַеhtml˺a
  • javascriptFȥHTML˺ķ
  • phptȥWеhtml,js,css,עጵČF
  • js@ȡhtmlclassNameڵăݲȥ˺
  • aspȥhtmlstyle,javascript,cssa
  • phpȥjs,html,cssa
  • JSPݔHTMLraĴո͓Qеȥ

P