create an HTML button with Onlick that aslo works as a link?
I have a button that adds a product to a basket - I would like to make the button when clicked add the product to the basket via the onclick script - then redirect to a page trough an a href link or similar. Is this possible?
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
对象:
function buy(...){
//your current code
window.location.href = "http://page to be redirected to";
}
链接地址: http://www.djcxy.com/p/36600.html
上一篇: css / html按钮链接不工作