首页 文章

使用Onlick创建一个HTML按钮,aslo作为链接?

提问于
浏览
0

我有一个按钮,可以将产品添加到购物篮中 - 我想在点击时按下按钮,通过onclick脚本将产品添加到购物篮中 - 然后通过href链接或类似方式重定向到页面 . 这可能吗?

HTML:

<input type="button" id="pl157821buy" class="actionbutton" value="Köp" onclick="buy(this, 157821, null, 'pl157821qty',null, '/ajax/buy')">

2 回答

  • 0

    不确定这是最佳做法,但您可以在致电 buy() 后立即使用 window.location.assign("/your/other/page") .

  • 0

    您可以使用 window.location 对象:

    function buy(...){
       //your current code
       window.location.href = "http://page to be redirected to";
    }
    

相关问题