我有一个按钮,可以将产品添加到购物篮中 - 我想在点击时按下按钮,通过onclick脚本将产品添加到购物篮中 - 然后通过href链接或类似方式重定向到页面 . 这可能吗?
HTML:
<input type="button" id="pl157821buy" class="actionbutton" value="Köp" onclick="buy(this, 157821, null, 'pl157821qty',null, '/ajax/buy')">
不确定这是最佳做法,但您可以在致电 buy() 后立即使用 window.location.assign("/your/other/page") .
buy()
window.location.assign("/your/other/page")
您可以使用 window.location 对象:
window.location
function buy(...){ //your current code window.location.href = "http://page to be redirected to"; }
2 回答
不确定这是最佳做法,但您可以在致电
buy()
后立即使用window.location.assign("/your/other/page")
.您可以使用
window.location
对象: