jsp页面字符串截取,点击弹出弹出层
1、jsp页面
<!--弹出层js--> <script type="text/javascript" src="mainpage/js/jquery_dialog.js"></script> <link rel="stylesheet" type="text/css" href="mainpage/css/jquery_dialog.css" /> <!--base64编码解码--> <script type="text/javascript" src="${path}/js/Base64-80.js"></script> <!--截取字符串--> <script type="text/javascript" src="${path}/js/dealstring.js"></script> <td title="<s:property value='#vl.virusFileName'/>"> <script type="text/javascript">document.write(dealLn("${vl.virusFileName}",24))</script> </td>
2、dealstring.js
/** * 字符串带有换行符且长度大于25时 进行处理 * @param text * @return */ function dealLn(text,length){ var strlen = 0; var s = ""; var str = text; if(null !=text && text.length>0){ for ( var i = 0; i < text.length; i++) { //一个汉字2个字符 if (text.charCodeAt(i) > 128) { strlen += 2; } else { strlen++; } s += text.charAt(i); if (strlen >= length) { text = s + "..."; break; } } } if(null != str && '' != str && "" != str){ str = encode64(str); } //encodeURI(encodeURI(str)) text = "<a style='text-decoration:none;color: black;' onclick=\"JqueryDialog.Open1('详情', '/common/logshow.jsp?message="+str+"',370, 120)\" >"+text+"</a>"; return text; }
3、Base64-80.js,base64编码
见附件
4、logshow.jsp,弹出层的jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'showLog.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <script language="javascript" type="text/javascript"> $(function(){ //decode64(decodeURI(decodeURI(''))); var ds = '<%=request.getParameter("message")%>'; if(ds!='null' && ds!=null && ''!=ds){ ds = ds.split(" ").join("+"); ds = decode64(ds); $("#detls").val(ds); $("#detls").css("display","block"); }else{ $("#detls").css("display","none"); } }); </script> </head> <body> <textarea id="detls" rows='8' cols='17' style='width: 350px; height: 100px;display: none;margin-left: 10px;'></textarea> </body> </html>
相关推荐
suis 2014-01-13
Hhjian 2014-05-31
83457317 2012-02-05
我只是个程序员 2015-09-11
87443561 2015-08-10
83510998 2015-05-19
suis 2015-05-11
DevilPace 2014-05-31
momode 2014-04-29
81423067 2014-03-12
lkj0 2014-01-13
海欣海夜 2013-04-18
89203856 2012-04-17
AnneZhao 2011-11-23
zhangyang0 2011-09-15
愚盦 2011-08-21
zfjdoreen 2011-03-30