最近在做项目中遇到一个问题,在安检结果返回界面时查看其明细不能正常显示,部分代码如下:
if(flag==false){
html+="<td width='50' align='left'><a href='javascript:void(0)' οnclick="getCheckDetail('"+brief+"','"+detail+"')">详细</a></td>";
}else{
html+="<td width='50' align='left'></td>";
}
function getCheckDetail(brief,detail){
var url = encodeURI("${base}/appuserlogic/getCheckUnpassDetail?brief="+brief+"&detail="+detail);
...........
}
经过测试调试修改为如下:
if(flag==false){
// js对特殊字符的转义
detail = detail.replace(/\\/g,"\\\\");
html+="<td width='50' align='left'><a href='javascript:void(0)' οnclick=\"getCheckDetail('"+brief+"','"+detail+"')\">详细</a></td>";
}else{
html+="<td width='50' align='left'></td>";
}