window.location() 与 GET 请求相同吗?

发布于 2024-08-15 12:35:34 字数 78 浏览 1 评论 0原文

如果 url 的域是当前页面的域,则在执行 windows.location(url) 时是否会保留 cookie?

Are cookies preserved while doing windows.location(url), if domain of url is the domain of the current page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天生の放荡 2024-08-22 12:35:34

说实话,在 Javascript 中更改 window.location 会导致浏览器转到另一个站点,其中包括发出 GET 请求。换句话说,GET 请求和 Javascript window.location 是两个完全不同的东西;一个是 HTTP 请求的类型,另一个是 DOM 属性。

但就问题而言,它们可以被认为是等效的。 Cookie 被保留。

:)

To be really pedantic, changing window.location in Javascript will cause the browser to go to another site, which includes making a GET request. In other words, a GET request and Javascripts window.location are two completely different things; one is a type of HTTP request, the other a DOM attribute.

As pertains to the question though, they can be considered equivalent. Cookies are preserved.

</pedantry> :)

等风来 2024-08-22 12:35:34

。这是同样的事情,它将保留所有 cookie。

Yes. It's the same thing and it will retain all cookies.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文