title: Javascript Output HTML
body: <p>I was wondering if someone could help me with this simple code I am trying to make a banner appear at the top of a webpage for cookies policy (click to agree etc) I have coded the PHP part fine and it makes and detects if cookie policy is agreed however I am having problems using a JS snippet to load the banner to the top of my page.</p>
  
  <p>This is what I am using to display the box and for the example about the code works fine displaying a hyperlink or text (as below) but if I try and add any other type of HTML for example a simple table like this it wont work.</p>
  
  <pre><code>&lt;table&gt;
    &lt;tr&gt;
      &lt;td&gt;Test&lt;/td&gt;
      &lt;td&gt;Table &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Sorry updated works with hyperlink</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function changeText()
  {
       document.getElementById("new_coder").innerHTML = '&lt;a href="#"&gt;sdsd&lt;/a&gt;';
  }
  &lt;/script&gt;
  &lt;b id='new_coder'&gt;Good Bye World&lt;/b&gt;
  &lt;input type='button'  value='Change Text'/&gt;
  </code></pre>
  
  <p>This is what I am trying to do </p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;script type="text/javascript"&gt;
  function changeText()
  {
       document.getElementById("new_coder").innerHTML = '&lt;table&gt;
    &lt;tr&gt;
      &lt;td&gt;Test&lt;/td&gt;
      &lt;td&gt;Table &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;';
  }
  &lt;/script&gt;
  &lt;b id='new_coder'&gt;Good Bye World&lt;/b&gt;
  &lt;input type='button' onclick='changeText()' value='Change Text'/&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Is there a better function for loading HTML snippets into a page via JavaScript. Sorry I am little sketchy on this area.</p>
  
  <p>Thanks Debs</p>