JS to achieve continuous English character automatic line-wrapping compatible IE6 IE7 and firefox_javascript skills

Source: Internet
Author: User

Copy Code code as follows:

Irefox in continuous English characters if you want to CSS control forced line, explore the N for a long time, found to be unable to achieve the forced when the use of JS script to control it

The English character wraps automatically, truncates the string through the JS script, this method general Ie6,ie7,firefox compatible solution

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>js to implement continuous English character wrapping </title>
<body>
<div id= "ff" style= "Width:500px;background: #f3f3f3;" >sssssssssssssssss

Sssssssssssssssssssssssssssssssssssssssssssssssss</div>
<script>
function Tobreakword (Intlen) {
var Obj=document.getelementbyid ("FF");/ID of the container where the text content resides
var strcontent=obj.innerhtml;
var strtemp= "";
while (Strcontent.length>intlen) {
Strtemp+=strcontent.substr (0,intlen) + "<br/>";
Strcontent=strcontent.substr (intlen,strcontent.length);
}
Strtemp+=strcontent;
Obj.innerhtml=strtemp;
}
Tobreakword (50);//The maximum number of characters in a line
</script>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.