Overview
This javascript function lets you detect the orientation of the device you website is browsed on. It does so by getting the devices screen height and width, and from there establishes if it is either Portrait or Landscape.
JavaScript Code:
<script type="text/javascript"> function codeAddress() { if(window.innerHeight > window.innerWidth){ //Portrait }else{ //Landscape } } window.onload = codeAddress; </script> <!-- CHECK IF DEVICE IS PORTRAIT --> window.addEventListener("orientationchange", function() { if(window.innerHeight > window.innerWidth){ //Portrait }else{ //Landscape } }, false);