Log in
Log into community
Join the Webstudio community
View all posts
Related posts
Was this helpful?
😞
😐
😃
Powered by
Hall
Inactive
Updated last month
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
last month
·
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
last month
Maybe use a button component instead?
And or use e.preventdefault
J
John Siciliano
last month
https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
J
Jeremy
last month
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
last month
Simplistically:
links = link to something
buttons = trigger some action (forms, js, action)
Amin
last month
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