title: Passing HTML string to JavaScript function
body: <p>I have a value that I'm currently accessing and passing to a JavaScript function through an <code>onclick</code>.</p>
  
  <pre><code>&lt;a href="#" onclick="openTextWindow('&lt;%=myVar.varDefinition.getText()%&gt;');"&gt;Text&lt;/a&gt;
  </code></pre>
  
  <p>An example value that I'd receive from the <code>getText</code> method is shown below.</p>
  
  <pre><code>&lt;h1&gt;My Header&lt;/h1&gt;&lt;br /&gt;My text
  </code></pre>
  
  <p>This value is then passed to my <code>openTextWindow</code> method.</p>
  
  <pre><code>function openTextWindow(inText) {
      myWindow = window.open('','','width=500, height=300');
      myWindow.document.write(inText);
      myWindow.focus();
  }
  </code></pre>
  
  <p>For some reason, the value stored in <code>inText</code> doesn't match the string with HTML tags that I showed above. It ends up looking like this.</p>
  
  <pre><code>"&lt;lt/&gt;h1&lt;gt/&gt;My Header&lt;lt/&gt;/h1&lt;gt/&gt;&lt;lt/&gt;br /&lt;gt/&gt;My text
  </code></pre>
  
  <p>When <code>inText</code> is written to <code>myWindow</code>, I want that new window to render with the text <code>My Header</code> within a styled header and <code>My text</code> on a line below that. I've tried replacing and escaping characters with no luck. Any ideas on how to fix this or a better way to accomplish what I'm trying to do? Thanks!</p>