title: JavaScript HTML escape button
body: <p>I am trying to make a button which would encode my link into ascii and than on click redirect me to that new encoded address.</p>
  
  <p>I already have the encoding part but the button just displays the converted code on click. I would like it instead to redirect me to that encoded page.</p>
  
  <pre><code>&lt;body&gt;
  
  &lt;p&gt;Click the button to encode a URI.&lt;/p&gt;
  
  &lt;button onclick="myFunction()"&gt;Try it&lt;/button&gt;
  
  &lt;p id="demo"&gt;&lt;/p&gt;
  
  &lt;script&gt;
  function myFunction() {
      var uri = "https://webpage.com/submit.do?firstName=Ždžrgr&amp;lastName=Žrđredj&amp;phone=(24324) 09942&amp;email=email@email.net”;
      var res = encodeURI(uri);
      document.getElementById("demo").innerHTML = res;
  }
  &lt;/script&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>Can someone please help me with this? I am new to JavaScript.</p>