title: With Chrome: Uncaught SyntaxError: Unexpected token <
body: <p>I am getting this error <strong>Uncaught SyntaxError: Unexpected token &lt;</strong> from chrome but everything works fine with FireFox.
  I have found many similar posts but no solution. </p>
  
  <p>So I am wondering if there is a way of sending a second page to the browser after it has been build, with it's own header.
  The idea came, when I saw that Firefox places, what I echo in the function below, after the html closing tag <em></em>, versus Chrome places it before the closing tag.</p>
  
  <p>Basically, I like to send in this order:</p>
  
  <pre><code>header('Content-Type: text/html; charset= utf-8');
  &lt;html&gt;&lt;/html&gt;
  
  header('Content-Type: text/javascript; charset= utf-8'); 
  &lt;script&gt;&lt;/script&gt;
  </code></pre>
  
  <p>This is my php script, I would like to uncomment the header code and send it independently from the html page. </p>
  
  <pre><code>public static function jsShow($html)
  {
      //header('Content-Type: text/javascript; charset= utf-8');
      echo "
          &lt;script type=\"text/javascript\"&gt;
          var e = document.getElementById('message');
          e.innerHTML = $html ;
          e.style.display = 'block';
          &lt;/script&gt;";
  }
  </code></pre>
  
  <p>This is what the page looks like in Firefox, and this works:</p>
  
  <pre><code>&lt;/body&gt;
  &lt;/html&gt;
  
  &lt;script type="text/javascript"&gt;
  var e = document.getElementById('message');
  e.innerHTML = &lt;ul style="list-style: none; margin: 0; padding: 0;"&gt;
  &lt;li style="background-color: #0000FF; margin: 0;"&gt;&lt;img src="/asset/icon/info.gif" alt="Info: " /&gt; working&lt;/li&gt;
  &lt;li style="background-color: #008000; margin: 0;"&gt;&lt;img src="/asset/icon/success.gif" alt="Success: " /&gt; Got it&lt;/li&gt;
  &lt;/ul&gt;
   ;
  e.style.display = 'block';
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I thought that I can maybe use ob_start() &amp; ob_end_flush(), but you can't control headers with that only content.</p>