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

jsp的button onclick事件 如何传带html标签的参数给js
jsp的button onclick事件 如何传带html标签的参数给js,下面的代码传简单的文字没有问题,但是传图文混排的文本就有问题了。
这是jsp:
<button type="button" onclick="f_show('${title}','${content}');">相关内容</button>
<label id="show"/>
这是js:
<script type="text/javascript">
function f_show(title,content)
{
document.getElementById("show").innerHTML = title+"<br>"+content;
}
</script>

查资料说,用escape和unescape编解码,但不会用。请各位高手帮帮小弟。
JSP JavaScript HTML 标签 函数

------解决方案--------------------
<button type="button" onclick="f_show('escape(${title}'),'escape(${content})');">相关内容</button>

document.getElementById("show").innerHTML = unescape(title)+"<br>"+unescape(content);

是这样吧
------解决方案--------------------
转义一下就好了