In a project, the HTML code for a large piece of text is not displayed on the phone because of the other table, and the TR/TD in the table table is carrying the style pasted from Word, which requires the table, TR, The style that is carried in TD is cleared away, and the table structure cannot be destroyed, that is, to retain the colspan attribute in RowSpan and TD in Tr.
The HTML part of the code is as follows:
<p class= "MsoNormal" align= "left" style= "Text-align:left" ><span lang= "en-US" > <o:p> Writings People's Republic of China writings People's Republic of China </o:p> </span></p> <table> <tbody> <tr style= "Height : 13.5pt "> <td width=" 117 "style=" Width:88.0pt;border:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:1 3.5pt "><p class=" MsoNormal "align=" center "style=" Text-align:center "><span style=" font-family: Song body; color
: #1F497D "> Project <span lang=" en-us "> <o:p></o:p> </span></span></p></td> <TD width= "137" style= "width:103.0pt;border:solid windowtext 1.0pt;border-left:none;padding:0cm 5.4pt 0cm 5.4pt;he Ight:13.5pt "><p class=" MsoNormal "align=" center "style=" Text-align:center "><span style=" font-family: XXFarEastFont-Arial ; color: #1F497D "> Amount <span lang=" en-us "> <o:p></o:p> </span></span></p></ Td> <td width= "153" style= "Width:115.0pt;border:solid Wind"Owtext 1.0pt;border-left:none;padding:0cm 5.4pt 0cm 5.4pt;height:13.5pt "><p class=" MsoNormal "center" Style= "Text-align:center" ><span style= "font-family: Song body; color: #1F497D" > Attn <span lang= "en-US" > <o: p></o:p> </span></span></p></td> <td width= "135" style= "width:101.0pt;border:s" Olid windowtext 1.0pt;border-left:none;padding:0cm 5.4pt 0cm 5.4pt;height:13.5pt "><p class=" MsoNormal "align=" Center "style=" Text-align:center "><span style=" font-family: Song body; color: #1F497D "> Have invoices <span lang=" en-US " > <o:p></o:p> </span></span></p></td> </tr> <tr style= "Heigh T:13.5pt "> <td width=" 117 "style=" Width:88.0pt;border:solid windowtext 1.0pt;border-top:none;padding:0cm 5.4pt 0cm 5.4pt;height:13.5pt "><p class=" MsoNormal "align=" center "style=" Text-align:center "><span style="
Font-family: Song body; color: #1F497D "> Total <span lang=" en-US "> <o:p></o:p> </span></span></p></td> <td colspan= "3" valign= "Bottom" nowr ap= "" style= "Width:103.0pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right: Solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:13.5pt "><p class=" MsoNormal "align=" Center "style=" Text-align:center "><span lang=" "en-us" style= "font-size:11.0pt;font-family: Song Body; Color:black" > <o:p> </o:p> </span></p></td> </tr> </tbody> </table> <p class= "MsoNormal" & Gt;<span style= "font-family: Song body; color: #1F497D" > Writings People's Republic of China writings People's Republic of China. </span><span lang= "en-US" style= "color: #1F497D" > <o:p></o:p> </span></p>
The JS script is as follows:
* * Format content, STR is HTML-formatted string/
function formatcontent (str) {
str=str.replace (/<\/? Html|head|title|meta|body) \b[^>]*>/ig, "");
Str=str.replace (/<table[^>]*>/ig, "<table>");
return str;
Str=str.replace (<tr[^>]*>)/ig, function (A, b) {
if (a.indexof (' rowspan ') >-1) {
a=a.replace ( [a-z]+] = "([^"]+)? " /ig,function (c,d,e) {return
D = = ' rowspan '? (d + ' = ' + E + ' "'): ';}"
return A;
} else{return
' <tr> '
}
);
Str=str.replace (<td[^>]*>)/ig, function (A, b) {
if (a.indexof (' colspan ') >-1) {
a=a.replace ( /([a-z]+) = "([^"]+)? " /ig,function (c,d,e) {return
D = = ' colspan '? (d + ' = ' + E + ' "'): ';}"
return A;
} else{return
' <td> '
}
);
return str;
}
The above mentioned is the entire content of this article, I hope you can enjoy.