title: Getting the User Agent with JavaScript
body: <p>I'd like to get a script that can grab the user's user agent and prop it to an attribute.</p>
  
  <p>I'm making a website problems contact form and I usually need to know what browser the user is using. How can I detect the user agent string and prop it as the value of an input element.</p>
  
  <p>My html looks something like:</p>
  
  <pre><code>&lt;input type="hidden" id="UserAgent" name="User Agent" /&gt;
  </code></pre>
  
  <p>I want the user agent to be added to that as the value attribute so it would look like:</p>
  
  <pre><code>&lt;input type="hidden" id="UserAgent" name="User Agent" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.53.11 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10" /&gt;
  </code></pre>