在警报中,单击ok进入下一页,单击cancel进入上一页,使用javascript

在警报中,单击ok进入下一页,单击cancel进入上一页,使用javascript,javascript,html,Javascript,Html,我需要一条消息,如下所示: 如果用户单击ok按钮(又名accept按钮),页面应重定向到下一页,如果用户单击go/back按钮,页面应重定向到上一页,是否有人可以就此事提出建议谢谢 目前,我需要提醒以下会议: if(total < total1){ alert('Total Grants & Others Spending should be LESS THAN Total State Tourism Office Spend Funding') return fa

我需要一条消息,如下所示:

如果用户单击ok按钮(又名accept按钮),页面应重定向到下一页,如果用户单击go/back按钮,页面应重定向到上一页,是否有人可以就此事提出建议谢谢

目前,我需要提醒以下会议:

if(total < total1){
    alert('Total Grants & Others Spending should be LESS THAN Total State Tourism Office Spend Funding')
    return false;
}
if(总计
您要查找的是
确认()
,而不是
警报()

if(总计
历史API仅在IE10及以上版本中受支持

if (confirm("something")) return true;
else {
  history.back();
  return false;
}
假设点击时链接已连接:

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
  }
}
window.onload=function(){
document.getElementById(“接受”).onclick=function(){
var total=…,total1=。。。;
如果(总计<总计1){
如果(确认('补助金和其他支出总额应小于州旅游局支出总额。是否继续?')){
返回true;
}
否则{
历史。返回();
返回false;
}
}
return true;//总计正常
}
}
使用


使用
确认

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;
                }

查找
confirm
而不是
alert
?通过“返回到上一页”,您实际上是指停留在当前页上,还是返回一步?通过“返回到上一页”和“下一页”,您是指URL,还是指下一页有历史标记,与单击浏览器中的“前进”按钮相同。我们是否必须在该消息中添加“返回”和“另一个接受/继续”等按钮?是否可以在if(redirect){return true;}中给出return true?这取决于此脚本的调用方式,是否有效?您没有为该按钮发布事件处理程序?您是否刚刚尝试过并查看它是否工作如果它位于锚事件处理程序中,您可以执行
window.location.href=this.href如果(total<a href="nextpage.html" id="accept">Accept</a>
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;
                }