window.location() 与 GET 请求相同吗?
如果 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
说实话,在 Javascript 中更改
window.location
会导致浏览器转到另一个站点,其中包括发出 GET 请求。换句话说,GET 请求和 Javascriptwindow.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 Javascriptswindow.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>
:)是。这是同样的事情,它将保留所有 cookie。
Yes. It's the same thing and it will retain all cookies.