title: How do you automatically run an external JavaScript function with a variable?
body: <p>I am trying to run an external javascript function when the page loads and the function takes a variable that I can only pass through the page which where the javascript function is called from.</p>
  
  <p>HTML Page</p>
  
  <pre><code>&lt;head&gt;
  &lt;script src="path/to/file.js" type="text/javscript&gt;
  window.onload = function() {
  doFunction(variable);
  }
  &lt;/script&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>Javascript file</p>
  
  <pre><code>function doFunction(variable){
  //do the stuff here
  }
  </code></pre>