title: Detect and redirect to mobile site
body: <p>A website I'm making has a separate set of files for mobile view due to the html layout being difficult to make responsive. </p>
  
  <p>I'm looking for code that will detect if the user is on a mobile, then redirect them to the m.website.com domain instead.</p>
  
  <p>I found this:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  if (screen.width &lt;= 699) {
  document.location = "YOUR-MOBILE-SITE.com";
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>But on most mobile devices, there is an option to view the desktop version of websites, but it looks like this javascript will ignore that and keep redirecting anyway.</p>
  
  <p>Is there a better way of doing this?</p>