title: How do I prevent internet explorer from rewriting my text?
body: <p>I have a javascript variable that contains an url, populated by outputting a script tag from php. The intention is to change the webpage to that url under certain circumstances.</p>
  
  <p><code>var url = "/somepage?q=3&amp;region=1";</code></p>
  
  <p>The problem is that the url contains the sequence "&amp;reg" which internet explorer changes to "®" without being asked.</p>
  
  <p>I've tried escaping the whole url with htmlspecialchars, which breaks other browsers. Turning off quirks mode might help, but it's not an option with the current system. Adding  to the script tag did nothing.</p>
  
  <p>edit:
  I figured out one solution, "escaping" the url with concatenation.</p>
  
  <p><code>var url = '&lt;?php implode( "&amp;'+'", explode( '&amp;', '/somepage?q=3&amp;region=1' ) ); ?>';</code></p>
  
  <p>I also realized I should probably mention how I change the page:</p>
  
  <p><code>document.location.href = url;</code></p>
  
  <p>edit:
  Turns out I had an error in my script tag. A minimal example that shows the same "problem":</p>
  
  <pre><code>&lt;script type="text/javascript" />
      var url = "/test?mode=preview&region=1";
  &lt;/script>
  </code></pre>
  
  <p>The self-closing start tag is the important thing here.</p>