Ana*_*mov 1 html javascript html5 onclick
我正在尝试确认然后重定向到新页面。
如果我return在confirm确认任何一种方法之前都删除了它,但是如果我保留return它,则不会重定向到链接。
<button name="payment" class="btn btn-xs-6 btn-danger btn-block" type="button"
onclick="return confirm('are you sure you want to cancel?');window.location.href='cancel';"
value="fav_HTML">Cancel Payment
</button>
Run Code Online (Sandbox Code Playgroud)
您需要输入的值confirm(),该值指示用户是否确认或取消。所以,代替
return confirm('are you sure you want to cancel?'); window.location.href='cancel';
Run Code Online (Sandbox Code Playgroud)
你应该做
if (confirm('are you sure you want to cancel?')) window.location.href='cancel';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1796 次 |
| 最近记录: |