如何为弹出按钮和提交按钮创建警告框?

时间:2016-02-09 06:47:52

标签: php laravel-5

我已完成提交按钮及其工作的警报。但对于同一页面,我有两个弹出按钮,他们也必须添加警报,但它不适合我。请帮忙:我的警报代码仅适用于提交按钮:

(function() {
  var proxied = window.alert;
  window.alert = function() {
    $("#myModal .modal-body").text(arguments[0]);
    $("#myModal").modal('show');
  };
  var myVar = setInterval(myTimer, 100000000000000000000);
})();
alert('SUCCESS');

function myTimer() {
  window.location.assign('job_schedule');;
}

function redirectfun() {
  window.location.assign('job_schedule');  
}
<!DOCTYPE html>
<html>

<head>
  <script src="http://code.jquery.com/jquery.min.js"></script>
  <link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
  <link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
  <script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap.js">
  </script>
  <meta charset=utf-8 />
  <title>JS Bin</title>
</head>

<body>
  <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria- labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
      <h3 id="myModalLabel">Alert</h3>
    </div>
    <div class="modal-body">
    </div>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" onclick="redirectfun()" aria-hidden="true">Close</button>
    </div>
  </div>

1 个答案:

答案 0 :(得分:0)

我不知道我是否真的理解你的问题,但你可以试试这个:

function your_function_name(){
    if (!confirm("Please Confirm - Yes or No?")) return;
    //following your codes ...
}