我的 jsp 遗留项目中有以下代码:
<tr>
<th colspan="2">Customer</th>
<td colspan="2">
<a href="myAction.do" target="view">CustomerLink</a></td>
</tr>
当我们单击 CustomerLink 时,我希望对行为进行少量修改。我只想在执行操作之前在 Javascript 函数中进行一些处理。我不知道如何在 Javascript 函数中模拟 href 链接行为?
我尝试过:-
<tr>
<th colspan="2">Customer</th>
<td colspan="2">
<a href="javascript:customerLinkClicked('myAction.do')" target="view">CustomerLink</a></td>
</tr>
// JavaScript 函数
function customerLinkClicked(path)
{
// simulate the href link behaviour, not sure how to do this
}
<a href="javascript:customerLinkClicked('myAction.do')" target="view">CustomerLink</a>
<script>
function customerLinkClicked(path) {
if (confirm('message'))
document.location.href = path;
}
</script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)