有人知道是否可以在 1 个按钮中使用 2 个 onclick 吗? 我希望在按下按钮时重新加载页面。
这是原始按钮:
<a href="javascript:;" onclick="javascript:articleToCart('<z:esc mode="js" value=$z:value[article.number]>', document.getElementById('amount$z:iteration[article.current]').value)">
最好的问候 弗兰克
编辑:
我的版本有效,但我找不到获取 return false
的方法上类。这适用于 IE 和 Firefox。
<center><input type="button" class="flowbutton" value="Kjøp" onclick="document.location.reload(true);javascript:articleToCart('<z:esc mode="js" value=$z:value[article.number]>',document.getElementById('amount$z:iteration[article.current]').value)"> </center>
最佳答案
如果您调用一个您已经执行过的函数,您可以在 javascript 中执行任意多的操作。
<script type="text/javascript">
function articleToCartMain() {
articleToCart('<z:esc mode="js" value=$z:value[article.number]>', document.getElementById('amount$z:iteration[article.current]').value);
//Put other function calls in here as well
return false; //Prevents the page from reloading or scrolling to top
}
</script>
<a href="#" onclick="return articleToCartMain();">Do something</a>
关于javascript - 使用其他 onclick 函数的 onclick 重新加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11134870/