javascript - How to create a window.location.replace() using sveltekit - Stack Overflow

Is there a way to create window.location.replace in SvelteKit, like we can use goto()?I want a way to

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.

Share Improve this question edited Oct 10, 2022 at 3:26 Michael M. 11.1k11 gold badges21 silver badges44 bronze badges asked Oct 9, 2022 at 18:45 da-navda-nav 511 silver badge3 bronze badges 3
  • 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
Add a ment  | 

1 Answer 1

Reset to default 6

There 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745186918a4615680.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信