Capturing the 'Back Button' event on a Mouse in Javascript

1 day ago 1
ARTICLE AD BOX

There are a several websites that, when you click on an item, it will show details with an overlay rather than a page change.

Consider a dog adoption website - when you click on a dog for adoption, rather than navigate to a new page (or use the history API), it displays details in a way that looks like a new page, but is actually an overlay, with a little 'x' in the upper corner. And, unless you remember to hit the tiny "X" in the corner, hitting back results in going to the wrong place.

This is bad design and drives me crazy, because it means that the back button on my mouse doesn't move "back".

I wanted to try to create a userscript I could use for the few sites that do this, so when I click on details, and those sites display a full-screen overlay, I could hit the back button on my mouse and have it close the overlay instead of navigating.

Is it possible to capture the mouse back button event and reroute it? I wouldn't be surprised if the answer is no for security reasons, but I wanted to check.

Read Entire Article