Implementation of Firefox CSS automatic line feed

Source: Internet
Author: User

Use ie directly:
Word-break: Break-all;/* line feed allowed */
Word-wrap: Break-word;/* The content will wrap in the boundary */
/* Note that the default value is :*/
Word-wrap: normal/* allow the content to open the specified window boundary */
Firefox does not have a good way to implement it. A compromise is to use the scroll bar, but a method to use js to judge the line feed is also proposed on the Internet, it is hereby stated ). Javascript Replication Code
<SCRIPT type = "text/JavaScript">
Function tobreakword (intlen, ID ){
VaR OBJ = Document. getelementbyid (ID );
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;
}
</SCRIPT>
Note: The above script is placed before

Single call on the same page:

<Div id = "content"> here is the content for applying line breaks </div> <SCRIPT type = "JavaScript"> tobreakword (60, "content"); </SCRIPT>
Multiple calls on the same page:

<Div id = "content"> here is the content for applying line breaks </div> <SCRIPT type = "JavaScript"> tobreakword (60, "content"); </SCRIPT>
<Div id = "content2"> here is the content to apply the line feed </div> <SCRIPT type = "JavaScript"> tobreakword (60, "content2"); </SCRIPT>

Note: Write the JavaScript code of the application behind . 60 indicates the number of characters to be displayed in a line. Pay attention to the corresponding change of the ID during multiple calls, the same ID name cannot be used. After the above method is applied, ie will also wrap the line according to the set number of characters, but ie supports automatic line feed, so you only need to determine whether it is IE, if it is not IE, do not output the above XML/html copy Code

This section of JS is output if not. The Code has not been tested. I only read the idea. If you need it, debug it yourself! Leave a message if an error occurs.

Related Article

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.