0
此处的目标是检测用户是否在我的网站上签出,然后在未选中某个框的情况下提示他们使用特殊提醒。将复选框提醒功能与检测功能结合
我如何结合两个功能来做到这一点?
的检测功能,到目前为止,这是
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);
这并不提供答案这个问题。要批评或要求作者澄清,在他们的帖子下留下评论 - 你总是可以评论你自己的帖子,一旦你有足够的[声誉](http://stackoverflow.com/help/whats-reputation),你会能够[评论任何帖子](http://stackoverflow.com/help/privileges/comment)。 – Dan 2014-10-03 01:07:05
当用户点击按钮时,onClick事件可以处理/调用他的两个方法 – WorkingMonk 2014-10-03 01:25:38