javascript - 使用其他 onclick 函数的 onclick 重新加载

标签 javascript onclick reload

有人知道是否可以在 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[art‌​icle.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/

相关文章:

Android:你如何让按钮在一段时间内不可点击?

javascript - jQuery onclick 在浏览器 Edge 中不起作用

json - 无需在 Swift 中关闭应用程序即可重新加载已解析的 URL

javascript - 如何在 window.location.reload() 之后打开模式

javascript - 重新加载然后在同一函数jquery中刷新

javascript - 在 jQuery 中,如何根据从下拉列表中选择的月份来增加年份

javascript - 我怎么读这个?

Javascript onclick 事件针对 id 触发,但不针对类触发

javascript - 我如何检查 Javascript 中的唯一性?

javascript - 使用 OpenLayers 和 GeoJSON 创建锥形线