Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何调用外部url?_Javascript_Angular_Typescript_Url_Angular Ui Router - Fatal编程技术网

Javascript 如何调用外部url?

Javascript 如何调用外部url?,javascript,angular,typescript,url,angular-ui-router,Javascript,Angular,Typescript,Url,Angular Ui Router,我正在使用angular 6制作一个应用程序,这里有两个URL 其中url 1为和 url 2是 这里,如果用户通过url 1登录,则只能重定向到url 2 然而,如果用户直接提供url作为,它应该重定向到进行登录 为此,我使用了以下内容: if (localStorage.getItem("isLoggedIn") === "true") { return true; } else { window.location.href = "authentication.hello.com";

我正在使用angular 6制作一个应用程序,这里有两个URL

其中url 1为和 url 2

这里,如果用户通过url 1登录,则只能重定向到url 2

然而,如果用户直接提供url作为,它应该重定向到进行登录

为此,我使用了以下内容:

if (localStorage.getItem("isLoggedIn") === "true") {
  return true;
} else {
  window.location.href = "authentication.hello.com";
}
这里我用过

window.location.href = "authentication.hello.com";
如果未登录,则重定向到身份验证

但是如果用户直接将url指定为,那么它将显示为,在这里它将被添加到指定的url中,但我需要的是,它应该删除,并且应该只有url,用户可以在其中看到登录屏幕

对于
window.location.replace(“authentication.hello.com”)
也会出现相同的结果,而我需要单独加载url
authentication.hello.com
,而不加载
application.hello.com
,如果不是loggedin


请帮助我使用纯javascript或typescript实现它。

使用完整URL在window.location.href中设置值:

window.location.href = "http://authentication.hello.com";