ckhatton
12/9/2014 - 8:33 PM

Sets the viewport depending on the device.

Sets the viewport depending on the device.

<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>