Skip to content

Instantly share code, notes, and snippets.

@manuelbieh
Last active October 13, 2015 08:28
Show Gist options
  • Save manuelbieh/4168162 to your computer and use it in GitHub Desktop.
Save manuelbieh/4168162 to your computer and use it in GitHub Desktop.
Allow scaling on iPhone when viewport has user-scalable=no
javascript:(function() { var v = document.querySelector("meta[name=viewport]"); var vc = v.content; if(!!vc.match('user-scalable')) { var as = vc.replace(/user-scalable\s*=\s*no/,'user-scalable=yes'); } else { var as = vc + ',user-scalable=yes'; } if(!!vc.match(/maximum-scale/)) { as = as.replace(/(,?)\s*maximum-scale\s*=\s*(.*)/,'$1maximum-scale=3') } else { as += ',maximum-scale=3'; } v.content = as; })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment