css 的方法: <style> a{ color: #cccccc; text-decoration: none; } a:hover{ color: purple; text-decoration: underline; } </style> <NOBR style="text-overflow:ellipsis;overflow:hidden;width:200px;color: #cccccc;"> <a href="#">The text will be hidden if overflow. The text will be hidden if overflow.</a> </NOBR> 还可以用java的String的subString方法,也就是在server端处理。就不说了。
var a=<%request.get("关键字")%>; var b="<%=request.get("搜索结果")%>"; document.write("..."+b.substring(b.indexOf(a)-20, b.indexOf(a)+20)+"...");
<style>
a{
color: #cccccc;
text-decoration: none;
}
a:hover{
color: purple;
text-decoration: underline;
}
</style>
<NOBR style="text-overflow:ellipsis;overflow:hidden;width:200px;color: #cccccc;">
<a href="#">The text will be hidden if overflow. The text will be hidden if overflow.</a>
</NOBR>
还可以用java的String的subString方法,也就是在server端处理。就不说了。
var b="<%=request.get("搜索结果")%>";
document.write("..."+b.substring(b.indexOf(a)-20, b.indexOf(a)+20)+"...");