0

The following webpage (let's call it test.html) behaves differently in Safari, Firefox, and Chrome. This question specifically relates to its behavior in Chrome.

<html>
  <body style="height: 200vh">
    <script>
      window.addEventListener('scroll', () => window.location.href = 'https://www.google.com')
    </script>
  </body>
</html>

If I start with an empty tab, go to test.html, scroll and thereby trigger the reroute to google.com, then click the back button, I'm sent to the empty tab page - even though test.html is visible in the history if you click and hold the back button. The forward button skips over it too.

I've tried a few things, including changing the listener to 'wheel', resetting the scroll location using onbeforeunload, and using a boolean flag to make sure the reroute only gets called once.

Any insight into what's happening here? Is this a Chrome bug, or working as intended?

  • What if you change the event? What about just using the reroute without the event? – evolutionxbox Jul 22 '20 at 19:51
  • 'keyup' and 'click' work fine. 'scroll' and 'wheel' cause the weird behavior. A normal reroute works fine too. – David Augustus Jul 23 '20 at 01:39
  • I can't replicate this. I get redirected immediately and if I go back it redirects mean immediately again. It must be a chrome issue. – evolutionxbox Jul 23 '20 at 14:57
  • You get redirected immediately? Even without scrolling? How is that possible? Is there a scroll event being triggered when you load the page for some reason? Can you test without the redirect? If this is a Chrome bug, where would be a good place to report it? – David Augustus Jul 23 '20 at 20:17
  • No that was in Firefox, not in Chrome. I can replicate your issue in Chrome. https://support.google.com/chrome/answer/95315?co=GENIE.Platform%3DDesktop&hl=en – evolutionxbox Jul 23 '20 at 20:44

0 Answers0