title: Changing body tag style through JavaScript
body: <p>I'm trying to write a script to change the width of the page, considering user's client width.
  It's something like this:</p>
  
  <pre><code>function adjustWidth() { 
      width = 0;
      if (window.innerHeight) {
          width = window.innerWidth;
      } else if (document.documentElement &amp;&amp; document.documentElement.clientHeight) {
          width = document.documentElement.clientWidth;
      } else if (document.body) {
          width = document.body.clientWidth;
      }
      if (width &lt; 1152) {
          document.getElementsByTagName("body").style.width="950px";
      }
      if (width &gt;= 1152) {
          document.getElementsByTagName("body").style.width="1075px";
      }
  }
  window.onresize = function() {
      adjustWidth();
  };
  window.onload = function() {
      adjustWidth();
  };
  </code></pre>
  
  <p>With this script I get an error from Firebug:</p>
  
  <pre><code>document.getElementsByTagName("body").style is undefined
  </code></pre>
  
  <p>Now my question is, how can i access the style of body? Because in the css sheet its selector and width property are defined.</p>