admin管理员组文章数量:1415491
Is there a way to create window.location.replace
in SvelteKit, like we can use goto()
?
I want a way to not save the current URL in history. The current URL has query strings that change and the user cannot use the back button to go to the previous page. Instead, just go to the page with different query strings.
Edit: I am using history.pushState()
and history.replaceState()
to not save the URLs in history. I wish there was a built-in way in SvelteKit to do this.
Is there a way to create window.location.replace
in SvelteKit, like we can use goto()
?
I want a way to not save the current URL in history. The current URL has query strings that change and the user cannot use the back button to go to the previous page. Instead, just go to the page with different query strings.
Edit: I am using history.pushState()
and history.replaceState()
to not save the URLs in history. I wish there was a built-in way in SvelteKit to do this.
-
What exactly is the problem?
replace
does not navigate, so why not just use it? – brunnerh Commented Oct 9, 2022 at 19:18 - replace pletely reloads the page making a few ponents useless. – da-nav Commented Oct 10, 2022 at 3:25
-
Sorry, what I meant was
history.replaceState
. There is no need for SvelteKit to have anything like that because it should not interact with its routing. – brunnerh Commented Oct 10, 2022 at 5:09
1 Answer
Reset to default 6There is a replaceState
parameter on goto
that may do what you're looking for.
goto('/wherever', { replaceState: true });
Looks like the options passed to goto
could be better documented, I'll see if I can fix that.
Current docs
本文标签: javascriptHow to create a windowlocationreplace() using sveltekitStack Overflow
版权声明:本文标题:javascript - How to create a window.location.replace() using sveltekit - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745186917a2646727.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论