Created
December 9, 2014 20:33
-
-
Save ckhatton/561581d017b3c5668921 to your computer and use it in GitHub Desktop.
Sets the viewport depending on the device.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<meta id="viewport" name='viewport'> | |
<script> | |
(function(doc) { | |
var viewport = document.getElementById('viewport'); | |
if ( navigator.userAgent.match(/iPhone|iPod/i) || screen.width <= 640) { | |
doc.getElementById("viewport").setAttribute("content", "initial-scale=0.3, maximum-scale=1.0, width=device-width"); | |
} else if ( navigator.userAgent.match(/Android|webOS|iPad|BlackBerry|IEMobile|Opera Mini/i) || screen.width > 640 ) { | |
doc.getElementById("viewport").setAttribute("content", "initial-scale=1.0, maximum-scale=1.0, width=device-width"); | |
} | |
}(document)); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment