gpt4 book ai didi

当页面等于 X 时,javascript 逻辑运算符不执行功能

转载 作者:行者123 更新时间:2023-12-03 08:15:58 25 4
gpt4 key购买 nike

我不想在 pageAge 或 pageMore 上执行 if 语句。当我转到 pageAge 时,它​​可以工作,它不会执行脚本,但当我转到 pageMore 时,它​​会执行脚本。我不确定在这种情况下使用哪个运算符。当我将 pageMore 放在 || 之前时,它可以在该页面上运行,但不能在其他页面上运行。

if ( top.location.pathname != pageAge || pageMore) {
//if not verified go to connect
$("body").css("display", "none");
if (age === null && top.location.pathname != pageConnect) {
window.location.href = pageConnect;
}
//if to young go to age page while cookie is found (1day)
if (age == toYoung) {
window.location.href = pageAge;
}
//if already verified go to like page.
if (age == legal && top.location.pathname === pageConnect) {
window.location.href = pageLike;
}
}

最佳答案

应该是:

if ( top.location.pathname != pageAge && top.location.pathname != pageMore)

关于当页面等于 X 时,javascript 逻辑运算符不执行功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33935672/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com