admin管理员组文章数量:1384604
What's the difference between window.location.assign(url)
and window.open(url, '_self')
?
Related questions:
- Difference between window.location.assign() and window.location.replace()
- What's the difference between window.open(url) and window.location.href = url on Firefox?
What's the difference between window.location.assign(url)
and window.open(url, '_self')
?
Related questions:
- Difference between window.location.assign() and window.location.replace()
- What's the difference between window.open(url) and window.location.href = url on Firefox?
- What did the related answers not answer for you? developer.mozilla/en-US/docs/Web/API/Location/assign vs developer.mozilla/en-US/docs/Web/API/Window/open – mplungjan Commented Mar 22, 2017 at 15:24
2 Answers
Reset to default 5Functionally? Not much. They do similar things in different ways.
Personally, I'd probably choose window.location over window.open. Even though they do the same things, using window.location for changing the current window is more mon, and doesn't require knowing about '_self', which isn't used that often. My experience is my coworkers expect window.open to involve opening a window versus reusing the same one.
window.location.assign
will assign the current window a new URL value. window.open
will open a new window (which may be in a new tab, or not, depending) with the value of the url passed.
It's the difference between creating a new window and editing an existing window.
本文标签:
版权声明:本文标题:javascript - Difference between window.location.assign(url) and window.open(url, '_self') - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744460416a2607207.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论