如何调用外部url?
How to call external url?
我正在使用 angular 6 制作一个应用程序,这里我有两个 urls,
其中 url 1 是 http://authentication.hello.com 并且
url 2 是 http://application.hello.com
如果用户通过 url 1 登录,则只能重定向到 url 2.
而如果用户直接将 url 作为 http://application.hello.com ,它应该重定向到 http://authentication.hello.com 进行登录。
为此我使用了以下内容,
if (localStorage.getItem("isLoggedIn") === "true") {
return true;
} else {
window.location.href = "authentication.hello.com";
}
这里我使用了
window.location.href = "authentication.hello.com";
如果未登录则重定向到身份验证。
但是如果用户直接将 url 作为 http://application.hello.com,那么它显示为 http://application.hello.com/authentication.hello.com,这里它被添加到给定的 url 但是我需要的是,它应该 删除 http://application.hello.com 并且应该只有 url 作为 http://authentication.hello.com 用户可以看到登录屏幕。
对于 window.location.replace("authentication.hello.com")
也会出现 http://application.hello.com/authentication.hello.com 的相同结果,而我需要单独加载 url authentication.hello.com
而无需 application.hello.com
如果没有登录。
请帮助我使用纯 javascript 或打字稿来实现它。
使用 Full URL 设置 window.location.href 中的值:
window.location.href = "http://authentication.hello.com";
我正在使用 angular 6 制作一个应用程序,这里我有两个 urls,
其中 url 1 是 http://authentication.hello.com 并且 url 2 是 http://application.hello.com
如果用户通过 url 1 登录,则只能重定向到 url 2.
而如果用户直接将 url 作为 http://application.hello.com ,它应该重定向到 http://authentication.hello.com 进行登录。
为此我使用了以下内容,
if (localStorage.getItem("isLoggedIn") === "true") {
return true;
} else {
window.location.href = "authentication.hello.com";
}
这里我使用了
window.location.href = "authentication.hello.com";
如果未登录则重定向到身份验证。
但是如果用户直接将 url 作为 http://application.hello.com,那么它显示为 http://application.hello.com/authentication.hello.com,这里它被添加到给定的 url 但是我需要的是,它应该 删除 http://application.hello.com 并且应该只有 url 作为 http://authentication.hello.com 用户可以看到登录屏幕。
对于 window.location.replace("authentication.hello.com")
也会出现 http://application.hello.com/authentication.hello.com 的相同结果,而我需要单独加载 url authentication.hello.com
而无需 application.hello.com
如果没有登录。
请帮助我使用纯 javascript 或打字稿来实现它。
使用 Full URL 设置 window.location.href 中的值:
window.location.href = "http://authentication.hello.com";