Hey guyz, i want to redirect to url to particular ...
# kobweb
a
Hey guyz, i want to redirect to url to particular section of a page, i have tried by the below code but it is not working, can you help me out for solution of this
i checked in the console it is saying id is not found, even i already set the id in the modifier
okay it is working now by adding LaunchedEffect
d
Ah, I see, you were trying to navigate before the page was set up
Still, you can usually just set the Page's href to include a fragment on the end and let the browser handle it -- I think that might be easier?
a
Yeah i will try that, thanks
d
Sorry I was busy earlier, I meant to include some code later and forgot
Try calling
ctx.router.tryRoutingTo("#example")
in a launched effect (using
rememberPageContext()
to get the context)
a
Will check it, but ctx is only available on the jvm side if i am not wrong🤔
Oh got it..... now thanks, i think this one is a better approach
d
Just in case for anyone lurking, here's more info on using the page context: https://github.com/varabyte/kobweb#page-context