【发布时间】:2014-06-01 21:42:50
【问题描述】:
您好,我有一个问题,我无法将包含空格的字符串值传递给 js 函数,我正在使用 jsonGenerator,这是我的代码:
jGenerator.writeStringField(cols[8],ap.getContentId() != null ? "<img src='img/active.png' onclick=authorizeContent("+ap.getContentId()+","+ ap.getName()+"); style='cursor:pointer;margin:0px 5px;width:18px;height:18px;'/> <img src='img/delete.png' onclick=authorizeContent('"+ ap.getContentId() +"','"+ ap.getName()+"'); style='cursor:pointer;margin:0px 5px;width:18px;height:18px;'/>" : "");
这是生成的 HTML
<td class="center"><img src="img/active.png" onclick="authorizeContent(47,la" diabla);="" style="cursor:pointer;margin:0px 5px;width:18px;height:18px;"> <img src="img/delete.png" onclick="authorizeContent('47','la" diabla');="" style="cursor:pointer;margin:0px 5px;width:18px;height:18px;"></td>
请帮忙,我也尝试过这种方法但没有成功:
jGenerator.writeStringField(cols[8],ap.getContentId() != null ? "<img src='img/active.png' onclick=authorizeContent('"+ ap.getContentId() +"','"+ ap.getName()+"'); style='cursor:pointer;margin:0px 5px;width:18px;height:18px;'/> <img src='img/delete.png' onclick=authorizeContent('"+ ap.getContentId() +"','"+ ap.getName()+"'); style='cursor:pointer;margin:0px 5px;width:18px;height:18px;'/>" : "");
和html
<td class="center"><img src="img/active.png" onclick="authorizeContent('47','la" diabla');="" style="cursor:pointer;margin:0px 5px;width:18px;height:18px;"> <img src="img/delete.png" onclick="authorizeContent('47','la" diabla');="" style="cursor:pointer;margin:0px 5px;width:18px;height:18px;"></td>
【问题讨论】:
标签: java javascript html json