【发布时间】:2019-05-26 02:06:18
【问题描述】:
如果网址包含某些条件,我希望将用户重定向到新网页。我似乎无法让 OR 条件起作用。有什么想法吗?
if (
document.location.href.indexOf("https://www.oct.ca/") > -1 &&
document.location.href.indexOf("professionally_speaking") > -1 &&
document.location.href.includes("2019-03" || "2018-12")
) {
window.location = window.location.href.replace("https://www.oct.ca/", "http://professionallyspeaking.oct.ca/")
}
【问题讨论】:
-
includes方法不接受该布尔条件(始终为真)。读起来听起来不错,但它对 JavaScript 没有意义。检查文档。
标签: javascript string if-statement conditional-statements boolean-expression