日期:2014-05-17  浏览次数:20687 次

过多文本,页面显示时,只显示部分
数据库中某个字段 :文本内容 :

<p class="MsoNormal" style="text-indent:30.0pt;mso-char-indent-count:2.5;
line-height:23.0pt;mso-line-height-rule:exactly"><span lang="ZH-CN" style="font-size:12.0pt;font-family:楷体_GB2312;mso-hansi-font-family:宋体">为了确保您能尽早,确保准确、高效,建议我们的合作分二步走。</span><span lang="EN-US" style="font-size:12.0pt;font-family:楷体_GB2312;mso-hansi-font-family:
宋体"><o:p></o:p></span><span style="font-family: 楷体_GB2312; font-size: 16px;">为了确保您能尽早,确保准确、高效,建议我们的合作分二步走。</span><span style="font-family: 楷体_GB2312; font-size: 16px;">为了确保您能尽早,确保准确、高效,建议我们的合作分二步走。</span><span style="font-family: 楷体_GB2312; font-size: 16px;">为了确保您能尽早,确保准确、高效,建议我们的合作分二步走。</span><span style="font-family: 楷体_GB2312; font-size: 16px;">为了确保您能尽早,确保准确、高效,建议我们的合作分二步走。</span><span style="font-family: 楷体_GB2312; font-size: 16px;">为了确保您能尽早,确保准确、高效,建议我们的合作分二步走。</span><span style="font-family: 楷体_GB2312; font-size: 16px;">为了确保您能尽早,确保准确、高效,建议我们的合作分二步走。</span><span style="font-family: 楷体_GB2312; font-size: 16px;">为了确保您能尽早,确保准确、高效,建议我们的合作分二步走。</span></p>


在页面中我要显示如下图所示




请问各位有什么好的解决办法 ???

------解决方案--------------------
先获取里面的string,然后splict截取
------解决方案--------------------
水了,是substr(),我记错了,随口就说了,等我给你写个
------解决方案--------------------
<!doctype html>
<html>
<head>
<title>css固定div层</title>
<meta charset="utf-8">
<script>
window.onload=function(){
var getContainer=document.getElementById('container');
var str=getContainer.innerHTML;
var newstr=str.substr(0,20);
document.getElementById('container').innerHTML=newstr+"...";
}
</script>
<style>
body{ margin:0px; padding:0px;}
</style>
</head>
<body>
<div id="container">欢迎来到马尔斯国度!但是我太长了!欢迎来到马尔斯国度!但是我太长了!欢迎来到马尔斯国度!但是我太长了!欢迎来到马尔斯国度!但是我太长了!欢迎来到马尔斯国度!但是我太长了!欢迎来到马尔斯国度!但是我太长了!欢迎来到马尔斯国度!但是我太长了!欢迎来到马尔斯国度!但是我太长了!</div>
</body>
</html>

------解决方案--------------------
引用:
不理解,能不能举例说明,谢谢


你的里面有html标签,你把js里的innerHTML全部替换成innerText就只会检测文字,不会对标签也检测了。