Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将复选框警报功能与检测功能相结合_Javascript_Jquery_Checkbox - Fatal编程技术网

Javascript 将复选框警报功能与检测功能相结合

Javascript 将复选框警报功能与检测功能相结合,javascript,jquery,checkbox,Javascript,Jquery,Checkbox,这里的目标是检测用户是否正在我的网站上签出,然后在他们取消选中某个框时向他们发出特别警报 如何将这两个函数组合起来 到目前为止,检测功能如下所示 var pathArray = window.location.pathname.split('/'); if (pathArray.length >= 3) { if (pathArray[1].toLowerCase() == "commerce") { var page = pathArr

这里的目标是检测用户是否正在我的网站上签出,然后在他们取消选中某个框时向他们发出特别警报

如何将这两个函数组合起来

到目前为止,检测功能如下所示

var pathArray = window.location.pathname.split('/');

      if (pathArray.length >= 3) {
        if (pathArray[1].toLowerCase() == "commerce") {

          var page = pathArray[2].toLowerCase();
          if (page.indexOf("show-cart") == 0) {
            console.log("Detected the cart page."); // This works
          } else if (page.indexOf("checkout") == 0) {
            console.log("Detected the checkout page."); // Does not work (no injection)
          } else if (page.indexOf("order-confirmed") == 0) {
            console.log("Detected the order confirmation page."); // Does not work (no injection)
          }
        }
      }
复选框警报功能如下所示:

function validate() {
        var checkoutHistory = document.getElementById('shipToBilling');
        if (checkoutHistory.checked) {

        } else {
            alert("You have elected to turn off checkout history.");
        }
    }
    window.addEventListener("load", validate, false);

onclick函数可以同时调用这两个函数

这并不能回答问题。若要评论或要求作者澄清,请在其帖子下方留下评论-您可以随时对自己的帖子发表评论,一旦您有足够的评论,您就可以发表评论。当用户单击按钮时,onClick事件可以处理/调用这两种方法