title: Javascript - Replacing the escape character in a string literal
body: <p>I am trying to replace the backslash (escape) character in a Javascript string literal. </p>
  
  <p>I need to replace it with a double backslash so that I can then do a redirect:</p>
  
  <pre><code>var newpath = 'file:///C:\funstuff\buildtools\viewer.html'.replace(/\\/g,"\\");
  window.location = newpath;
  </code></pre>
  
  <p>However, it seems to have no result. </p>
  
  <p>I don't have the option of properly escaping the backslashes before they are handled by Javascript.</p>
  
  <p>How can I replace (\) with (\\) so that Javascript will be happy?</p>
  
  <p>Thanks,
  Derek</p>