如果URL包含某些条件,我希望将用户重定向到新网页。我似乎无法使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/")
}
答案 0 :(得分:1)
您不能那样做-添加其他条件:
&& (document.location.href.includes("2019-03") || document.location.href.includes("2018-12"))