Last Updated: February 25, 2016
·
1.411K
· benjamincharity

Lock iOS zoom until a user manually zooms.

// lock the zoom unless the user is manually zooming
var viewportmeta = document.querySelector('meta[name="viewport"]');
if (viewportmeta) {
  viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
  document.body.addEventListener('gesturestart', function () {
    viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
  }, false);
}

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside