首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

JS兑现段落内换行

2012-10-17 
JS实现段落内换行问题出在哪里啊,下面贴代码,求高人解答!!!!!!!!我就是想问下,那个P里面的段落如何实现分

JS实现段落内换行
问题出在哪里啊,下面贴代码,求高人解答!!!!!!!!

我就是想问下,那个P里面的段落如何实现分段啊,就是类似BR之类的功能,
我指定多少个字符,出现一次BR

JScript code
<script type="text/javascript">function autoBr(max1){var maxVal=document.getElementById("right");var maxVal_Val=maxVal.childNodes.item(1).childNodes.item(0);var maxVal_3=maxVal.childNodes.item(1);var final_var=maxVal_3.innerHTML;var final_Length=maxVal_3.length;var temp="";while(final_Length>max1){    temp=temp+final_var.substr(0,max1)+"\n";    final_var=final_var.substr(max1,final_Length);}temp=temp+"\n"+final_var;final_var=temp;}function testYes(){    autoBr(10);    }</script>


HTML code
<body onload="testYes()"><div id="right">      <h3 class="title"><a href="<!--{$url_about}-->" title="More" class="more">More</a><span>公司简介</span></h3>      <div class="text">        <div class="editor">                    <!--{if $ads_zone2}-->          <!--{foreach $ads_zone2 as $volist}-->          <img width="<!--{$volist.width}-->" height="<!--{$volist.height}-->" hspace="2" align="left" vspace="2" src="<!--{$volist.uploadfiles}-->" style="float:right" />          <!--{/foreach}-->          <!--{/if}-->          <p><!--{$config.about|filterhtml:435}--></p>        </div></body>



[解决办法]
你为什么不把 +"\n" 换成 +"<br/>"呢?

热点排行
Bad Request.