Log in
Log into community
Join the Webstudio community
New post
View all posts
Related posts
Was this helpful?
😞
😐
😃
Powered by
Hall
Inactive
Updated 2 months ago
0
Follow
How To Stop Link Component From Scrolling To The Top?
How To Stop Link Component From Scrolling To The Top?
Inactive
0
Follow
At a glance
Amin
2 months ago
·
I have link "button" which doesn't go to an external website but triggers something in my script, but while it triggers my script it also scrolls back to the top of the site, but I don't want that to happen. How can I overcome this?
J
J
5 comments
Share
Open in Discord
J
John Siciliano
2 months ago
Maybe use a button component instead?
And or use e.preventdefault
J
John Siciliano
2 months ago
https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
J
Jeremy
2 months ago
https://youtu.be/CLY_Kj8Qdr0?si=-PK4Yw1D5I-IQbXj
at 35s the define the difference between a link and button. It's a good rule to follow.
J
Jeremy
2 months ago
Simplistically:
links = link to something
buttons = trigger some action (forms, js, action)
Amin
2 months ago
Thank you, I didn't use a button because a long time ago it wouldn't work with my script but somehow now it does work
Add a reply
Sign up and join the conversation on Discord
Join on Discord