如果 url 符合某些条件,则重定向用户
Redirect user if url matches certain conditions
如果 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/")
}
你不能那样做 - 添加另一个条件:
&& (document.location.href.includes("2019-03") || document.location.href.includes("2018-12"))
如果 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/")
}
你不能那样做 - 添加另一个条件:
&& (document.location.href.includes("2019-03") || document.location.href.includes("2018-12"))