#Help to redirect to a specific section

28 messages · Page 1 of 1 (latest)

digital adder
#

i want the user to get redirected to another route but in a specific section holding the id banner
redirect("/success#banner");
but its not working. what's wrong?

buoyant flowerBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

winter mortarBOT
# digital adder i want the user to get redirected to another route but in a specific section hol...
Please add more information to your question

Your question currently does not have sufficient information for people to be able to help. Please add more information to help us help you, for example: relevant code snippets, a reproduction repository, and/or more detailed error messages. See more info on how to ask a good question in https://discord.com/channels/752553802359505017/1138338531983491154 and #welcome message

digital adder
#

here is my redirect function

#

but i get this

slow stump
#

@digital adder First before I assume something else, do you actually have an element with id={"banner"?

digital adder
#

and when i manualy use /success#banner

#

it works

slow stump
#

Then It's the redirect call.

digital adder
digital adder
slow stump
#

It's probably that redirect isn't able to pass query, because it's not trying to fetch, that would be my guess.

slow stump
#

Is this on the server?

digital adder
#

no

#

i mean

#

yes

#

sorry

slow stump
#

Oh, well if it was on the client you could do:

export default component() {
 const router = useRouter()
 router.push("/success#banner")
 return ([...])
}
#

@digital adder Is your success page on the client?

digital adder
#

yes

#

it is

slow stump
#

Oh that makes it easy

#

Just have this inside your page

useEffect(() => {
 var banner = /* Define your element */
 banner.scrollIntoView({behavior: "smooth"})
},[])
#

So that will automatically scroll to the banner whenever the page loads

#

just make sure its obviously in the top level of your page, and ofc import useEffect

digital adder
#

@slow stump thank you so much!