I am trying to confirm then redirect to new page.
if I delete return
before confirm
it confirms either way but if I keep return
it does not redirect to link.
<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>
I am trying to confirm then redirect to new page.
if I delete return
before confirm
it confirms either way but if I keep return
it does not redirect to link.
<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>
Share
Improve this question
edited Feb 8, 2016 at 17:38
LostMyGlasses
3,15422 silver badges29 bronze badges
asked Feb 8, 2016 at 17:07
Anar BayramovAnar Bayramov
11.6k6 gold badges48 silver badges68 bronze badges
1
- lol why this question is down voted? I don't see anything against stackoverflow rules. – Anar Bayramov Commented Feb 8, 2016 at 17:46
2 Answers
Reset to default 8You need the value of confirm()
, which indicates if the user confirmed or cancelled. So, instead of
return confirm('are you sure you want to cancel?'); window.location.href='cancel';
you should do
if (confirm('are you sure you want to cancel?')) window.location.href='cancel';
r = confirm('are you sure you want to cancel?');
if (r == true) {
window.location.href='cancel';
} else {
//
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744172822a4561616.html
评论列表(0条)