IOS 7 - is there a way to disable swipe functions back and forth in Safari?

For some web pages, we use the left and right scroll function of the iPhone to pull out the menu. Now with iOS7, they have introduced the ability to go back and go to the previous and subsequent pages of the browser history to scroll left and right movements.

But is there a way to disable it for certain pages so as not to have conflicting behavior when doing swipe actions?

+70
safari ios ios7
Sep 19 '13 at 8:24
source share
4 answers

No, this is done at the OS level and the webpage does not receive a callback

See this summary of safari changes in iOS7 that may cause problems on your website (including this gesture)

+15
Sep 19 '13 at 8:51 on
source share

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

It will not work in every case, but if you have a one-page web application opened in a new tab, you can prevent it from being added to the history using

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

instead of pushState or

 document.location.hash = url 
+11
Apr 19 '14 at 4:46
source share

I had to use two approaches:

1) CSS only 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 overcroll-behavior-x, and we can remove the JS hack

+2
Feb 12 '18 at 11:43
source share

Apple has provided recommendations on how to recognize and cancel gestures. See Here: Prevent Scrolling Between Web Pages in iPad Safari

0
Dec 6 '18 at 17:04
source share



All Articles