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事件可以处理/调用这两种方法