<!DOCTYPE html PUBLIC "//WC//DTD XHTML Transitional//EN" " <html xmlns=" <head> <meta httpequiv="ContentType" content="text/html;charset=gb" /> <title>文字自动分插不同的divJason Yu</title> <style type="text/css"> *{margin:;padding:;} body{lineheight:px;fontfamily:SimSun;fontsize:px;color:#;} #box{height:px;} box{width:px;overflow:hidden;margintop:px;border:px solid #;} </style> </head> <body> <div id="box" class="box"></div> <script type="text/javascript"> var str = "这里是一段话这短话的文字可以很随意的哦只要达到一定数量就自动会分页你信不信?不信也得信啊这是真的哪怕再长的文字我复制一段话吧下面这一段话就是复制过来的我要准备复制了哦准备好了没呢?这里是一段话这短话的文字可以很随意的哦只要达到一定数量就自动会分页你信不信?不信也得信啊这是真的哪怕再长的文字我复制一段话吧下面这一段话就是复制过来的我要准备复制了哦准备好了没呢?"; var oBox = documentgetElementById("box"); function fnTextOver(n){ var newBox = documentcreateElement("div"); documentbodyappendChild(newBox); newBoxclassName = "box"; for(var i=n; i<=strlength; i++){ newBoxinnerHTML = strsubstring(ni); if(newBoxoffsetHeight<=){ if(i==strlength){ newBoxstyleheight = "px"; } }else{ newBoxinnerHTML = strsubstring(ni); newBoxstyleheight = "px"; argumentscallee(i); break; } } }
function fnShowText(){ var newBox = documentcreateElement("div"); documentbodyappendChild(newBox); newBoxclassName = "box"; for(var i=; i<=strlength; i++){ newBoxinnerHTML = strsubstring(i); if(newBoxoffsetHeight<=){ oBoxinnerHTML = strsubstring(i); if(i==strlength){ documentbodyremoveChild(newBox); } }else{ documentbodyremoveChild(newBox); fnTextOver(i); break; } } } fnShowText(); </script> </body> </html> |