title: Pure JavaScript: Combine onload and onresize in one function?
body: <p>A bit stuck here.</p>
  
  <p>I'm trying to display and output the live(responsive) height and width of the inner page.</p>
  
  <p>In this code, I feel like I am repeating myself to much. Is there anyway to make the code look cleaner or put it in one function?</p>
  
  <p>Personally, I don't want to use JQuery in this case.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var pageSize = document.getElementById("innerSize");
  
  window.onload = function() {
    var w = document.documentElement.clientWidth;
    var h = document.documentElement.clientHeight;
  
    pageSize.innerHTML = "Width: " + w + "&lt;br&gt;" + " Height: " + h;
  }
  
  window.onresize = function() {
    var w = document.documentElement.clientWidth;
    var h = document.documentElement.clientHeight;
  
    pageSize.innerHTML = "Width: " + w + "&lt;br&gt;" + " Height: " + h;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="innerSize"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>