There's these web browser extensions that let you disable JavaScript for that reason.
Websites can do way more than just hijack your browser button if your browser just runs any and all JS it receives. See for example https://theannoyingsite.com/ but at your own risk.