2016-06-02 22:00:06 连续长字段自动换行
火狐firefox浏览器下如何使连续长字段自动换行实现
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-language" content="zh-cn" />
- <meta http-equiv="content-type" content="text/html;charset=gb2312" />
- <title>blueidea</title>
- <style type="text/css">
- div {width:300px;word-wrap:break-word;border:1px solid red;}
- </style>
- </head>
- <body>
- <div id="ff">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
- <script type="text/javascript">
- // <![CDATA[
- function toBreakWord(intLen){
- var obj=document.getElementById("ff");
- var strContent=obj.innerHTML;
- var strTemp="";
- while(strContent.length>intLen){
- strTemp+=strContent.substr(0,intLen)+"
- ";
- strContent=strContent.substr(intLen,strContent.length);
- }
- strTemp+="
- "+strContent;
- obj.innerHTML=strTemp;
- }
- if(document.getElementById && !document.all) toBreakWord(37)
- // ]]>
- </script>
- </body>
- </html>
众所周知IE中直接使用 word-wrap:break-word 就可以了, 这里FF中我们使用JS插入的方法来解决