Many friends in the process of making Web pages always found that some time some English will put the original good form to distraction and lead to deformation, although you can use style= "Table-layout:fixed;word-wrap:break-word;word-break: Break-all "To solve this problem, but sometimes it will cause the content display is not complete and is hidden, and did not do the effect of automatic wrapping.
So I want to write a function to fix this flaw, this function is very simple, but here only provides a way to solve this problem.
function FNADDBR (ID, Iperlinelen) {...}
ID is the length of each line for the Id,iperlinelen of the text block to be modified
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" > <ptml> <pead> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/> <title>untitled document</title> </pead> <body> <script type=" Tex T/javascript ">/function Function: Automatically add line breaks at specified lengths, in English length, and 8 for 8 English or 4 Chinese characters function fnaddbr (ID, iperlinelen) {var Sstr=document.getelementbyid (ID). InnerHTML; if (Sstr.replace (/[^\x00-\xff]/g, "xx"). Length <= Iperlinelen) {return-1; } var str= ""; var l=0; var Schar; For (var i=0;schar=sstr.charat (i); i++) {Str+=schar; l+= (Schar.match (/[^\x00-\xff]/)!=null?2:1); if (l>= iperlinelen) {str+= "\ n"; l=0; } document.getElementById (ID). innerhtml=str; } </script> <divid= "Content" > What I add when I make a Web page is always horizontal to make the form stand wide and hard to see; I'm adding style= "Table-layout:fixed;word-wrap:break-word;word-bre Ak:break-all "This code, the table will not be wide, but the content is not complete, just show the same width of the table content, the other is blocked or filtered out. My character is Chinese, does this matter? Is there any way to make the text in the table to the number of words to automatically change the line? Or can change lines and do not support large forms, and do not omit content! My content is called in the dynamic of this tag! </div> <div id= "Content1" > The content I added when I was doing the Web page was always wide and hard to look at when I created the page. I'm adding style= "Table-layout:fixed;word -wrap:break-word;word-break:break-all "This code, the table will not be wide, but the content is not complete, just show the same width of the table content, the other is blocked or filtered out. My character is Chinese, does this matter? Is there any way to make the text in the table to the number of words to automatically change the line? Or can change lines and do not support large forms, and do not omit content! My content is called in the dynamic of this tag! </div> <script type= "Text/javascript" > Fnaddbr ("Content", 25); FNADDBR ("Content1", 50); </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]