[英]in alert clicking ok has go to next page and clicking on cancel has to go to previous page using javascript
I need to have a message to be alerted as follows : 我需要有一条消息被警告,如下所示:
If the user clicks on ok button aka accept button the page should be redirected to next page and if the user clicks on go/back button it should redirect to the previous page, Can someone suggest anything on this matter thanks. 如果用户单击“确定”按钮又称为“接受”按钮,则该页面应重定向到下一页;如果用户单击“转到/返回”按钮,则应重定向到上一页。有人可以对此提出建议吗,谢谢。
At present i need to alert following meesage : 目前,我需要提醒以下消息:
if(total < total1){
alert('Total Grants & Others Spending should be LESS THAN Total State Tourism Office Spend Funding')
return false;
}
if (confirm("something")) return true;
else {
history.back();
return false;
}
assuming a link wired up on click: 假设在点击时链接了一个链接:
window.onload=function() {
document.getElementById("accept").onclick=function() {
var total = ..., total1=...;
if (total < total1) {
if (confirm('Total Grants & Others Spending should be LESS THAN Total State Tourism Office Spend Funding. Continue anyway?')) {
return true;
}
else {
history.back();
return false;
}
}
return true; // total was ok
}
}
using 运用
<a href="nextpage.html" id="accept">Accept</a>
You're looking for confirm()
, not alert()
您正在寻找的是
confirm()
,而不是alert()
if(total < total1) {
var redirect = confirm('Total Grants & Others Spending should be LESS THAN Total State Tourism Office Spend Funding');
if (redirect) {
window.location.href = 'nextpage.html';
}else{
window.history.back();
// or window.history.go(-1);
}
}
The History API is only supported in IE10 and up 仅在IE10及更高版本中支持History API
Use confirm
. 使用
confirm
。
var r = confirm('Total Grants & Others Spending should be LESS THAN Total State Tourism Office Spend Funding');
if (r == true) {
// do if yes,
} else {
// do if no.
return false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.