That bloody iPhone/iPad orientation zoom bug, fixed at last!

if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
  var viewportmeta = document.querySelector('meta[name="viewport"]');
  if (viewportmeta) {
    viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0';
    document.body.addEventListener('gesturestart', function() {
      viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
    }, false);
  }
}

I’ve been so very annoyed at the bloody iPad and iPhone bug where the zoom gets messed up if you would do something as daring as going from portrait to landscape orientation. This handy javascript snippet fixes it so well. Thanks Jeremy!

Oh, one little thing: Using this means that you have to pinch twice to zoom the page. I think it’s worth it to fix this bug.

Courtesy of Jeremy Keith

Comments? Tweet me!