iOS 7 - is there a way to disable the swipe back and forward functionality in Safari? iOS 7 - is there a way to disable the swipe back and forward functionality in Safari? ios ios

iOS 7 - is there a way to disable the swipe back and forward functionality in Safari?


No, this is done at the OS level, and webpage doesn't get any callback

See this summary of safari changes in iOS7 that might cause problems to your website (including this swipe gesture)


You can't disable it directly, but the native swipe back only happens if there is something in the browser history.

It won't work in every case, but if you have a single page web app opened in a new tab, you can prevent it from adding to the history by using

window.history.replaceState(null, null, "#" + url)

instead of pushState or

document.location.hash = url


I had to use 2 approaches:

1) CSS only fix for Chrome/Firefox

html, body {    overscroll-behavior-x: none;}

2) JavaScript fix for Safari

if (window.safari) {    history.pushState(null, null, location.href);    window.onpopstate = function(event) {        history.go(1);    };}

Over time, Safari will implement overscroll-behavior-x and we'll be able to remove the JS hack