Monday, December 23, 2013

JavaScript has an event which is triggered when you resize a browser window.

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="utf-8">
      <title>Whatever</title>
      </style>
   </head>
   <body>
      <div id="whatever"></div>
      <script type="text/javascript">
         window.onresize = function(event) {
            var winWidth = document.all ? document.body.clientWidth : window.innerWidth;
            var winHeight = document.all ? document.body.clientHeight : window.innerHeight;
            document.getElementById('whatever').innerHTML = winWidth + "x" + winHeight;
         }
      </script>
   </body>
</html>

No comments:

Post a Comment