我想在用户单击“编辑”链接时显示一个弹出窗口。我已经编写了下面提到的代码。 链接:-
<a href=javascript:MyFunc('${someVariable}');>EDIT</a>
javascript:-
<script type="text/javascript">
function MyFunc(somevariable){
<c:set var="someVariable" **value="123"**/>
var answer=confirm("do you want to edit")
if(answer)
window.location="<c:url value='/edit/${someVariable}'/>";
}
当我使用某些用户定义的值时,它可以工作,但我无法从链接传递变量的值。
请您参考如下方法:
我会尝试:而不是 anchor 标记中的 MyFunc('${someVariable}') :
MyFunc('<c:out value='${someVariable}'/>')
此外,您可能希望从 window.location 中提取出 ${someVariable}:
window.location="<c:url value='/edit'/>" + "/" + someVariable