Home  >  Article  >  Web Front-end  >  js realizes automatic line wrapping of continuous English characters and is compatible with ie6 ie7 and firefox_javascript skills

js realizes automatic line wrapping of continuous English characters and is compatible with ie6 ie7 and firefox_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:23:191129browse

Copy code The code is as follows:

If you want CSS to control forced line breaks for continuous English characters in irefox, After exploring for a long time, I found that it is impossible to achieve. When I have to use js script to control it,

English characters are automatically wrapped and the string is truncated through js script. This method is compatible with ie6, ie7 and firefox.





js implements automatic line wrapping of continuous English characters


ssssssssssssssssss

sssssssssssssssssssssssssssssssssssssssss< ;/div>
<script> <br>function toBreakWord( intLen){ <br>var obj=document.getElementById("ff");//The id of the container where the text content is located <br>var strContent=obj.innerHTML; <br>var strTemp=""; <br>while( strContent.length>intLen){ <br>strTemp =strContent.substr(0,intLen) "<br />"; <br>strContent=strContent.substr(intLen,strContent.length); <br>} <br>strTemp =strContent; <br>obj.innerHTML=strTemp; <br>} <br>toBreakWord(50);//The maximum number of characters in a line<br></script>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn