Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop chrome back/forward two finger swipe

I want to disable the two finger swipe that causes Chrome going back or forward. I have a website where the user might lose progress on his work if he doesn't specifically saves.

I have tried using window.onbeforeunload but that doesn't seem to work if I have hashes in the url (back forward would change between www.example.com/work/#step1#unsaved www.example.com/work/#step0) and the event doesn't seem to trigger.

I was about to switch to another solution but today I noticed that in Google Docs it's completely disabled. How did they achieve that?

like image 728
andrei Avatar asked Apr 05 '13 08:04

andrei


People also ask

How do I turn back swipe off?

You can't turn off the gesture navigation for the right side in spite you can use try changing the sensitivity of the right/left side or try 3 button navigation. To change sensitivity Go to settings>system>gesture>system navigation settings and try changing the sensitivity for the right side.

How do I turn swipe back to Chrome?

Open up Chrome for Android and type “chrome://flags” in the address bar at the top. Once in the flags area, type “history nav” in the search bar. When you see the “History navigation with gesture” option, tap the box where it says “Default.” Tap on the “Enable” option.


2 Answers

Disable Chrome two fingers back/forward swipe

This worked for me:

body {   overscroll-behavior-x: none; } 
like image 128
Breck Avatar answered Sep 29 '22 11:09

Breck


Make the specific page open in a new tab/window by default (by putting target="_blank"> in hyperlink). That way there'll be no previous page to go back to.

Or prevent Horizontal Scrolling by default. To do that, you can use jquery.mousewheel to do:

$(document).on("mousewheel",function(event,delta){    // prevent horizontal scrolling   if (event.originalEvent.wheelDeltaX !== 0) {     event.preventDefault();   }  }); 
like image 31
redgetan Avatar answered Sep 29 '22 09:09

redgetan