Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Improved version of JavaScript fix for the iOS viewport scaling bug. See , also
(function() {
var metas = document.querySelectorAll('meta[name="viewport"]'),
forEach = [].forEach;
function fixMetas(firstTime) {, function(el) {
el.content = firstTime
? 'width=device-width,minimum-scale=1.0,maximum-scale=1.0'
: 'width=device-width,minimum-scale=0.25,maximum-scale=1.6';
document.body.addEventListener('gesturestart', fixMetas, false);

I’d love to re-use the argument var instead of creating a new one (scales), but I can’t think of a flexible enough variable name. :)


cheeaun commented Apr 4, 2011

@mathiasbynens Perhaps just re-use the passed firstTime variable instead of creating the new scales? :P

@cheeaun Yeah that’s what I’m talking about. I’d have to rename the variable for clarity though, and I can’t think of a good name that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment