Patrick's answer is useful, here is a more verified version
var checkOrientation; checkOrientation = function() { var viewport; viewport = document.querySelector("meta[name=viewport]"); if (window.orientation === 90 || window.orientation === -90) { return viewport.setAttribute("content", "width:device-width, initial-scale=1.0, user-scalable=1"); } else { return viewport.setAttribute("content", "width:device-width, initial-scale=0.6, user-scalable=1"); } }; window.onorientationchange = function() { return checkOrientation(); }; checkOrientation();
And don't forget to put this in the head of the document:
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
Note that one of the differences is the comma instead of half-columns in the arguments
source share