title: How do i pass string with escape characters in javascript?
body: <p>There are many such questions here,but none of them was able to solve my question.I am trying to implement a simple toggle switch between "See more" and "See less" in SWT Browser in a java application.I am using this code with some changes
  <a href="http://jsfiddle.net/8u2jF/" rel="nofollow">http://jsfiddle.net/8u2jF/</a></p>
  
  <p>My code would be something like</p>
  
  <pre><code>&lt;div&gt;
      &lt;p id="textArea"&gt;&lt;!-- This is where I want to additional text--&gt;&lt;/p&gt;
  &lt;/div&gt;
  
  
  &lt;a id="toggleButton" onclick="toggleText(encodeURI('hsd\\nhe'));" href="javascript:void(0);"&gt;See More&lt;/a&gt;
  
  var status = "less";
  
  function toggleText(s)
  {
      var text="Here is some text that I want added to the HTML file";
  
      if (status == "less") {
          document.getElementById("textArea").innerHTML=decodeURI(s);
          document.getElementById("toggleButton").innerText = "See Less";
          status = "more";
      } else if (status == "more") {
          document.getElementById("textArea").innerHTML = "";
          document.getElementById("toggleButton").innerText = "See More";
          status = "less"
      }
  }
  </code></pre>
  
  <p>But when i run this \n is not taken as a new line character?How do i make Javascript understand that it is newline character?</p>
  
  <p>I will be using this script in java SWT application and invoke it using SWT Browser.I will pass a string as a parameter which might contain any escape character.How do i handle them?</p>