JavaScript deleting all other elements
<p>So I am working in Chatango's profile HTML embedding and it was going really smoothly until i added my javascript to automate the background image. Once I put the script into the site it erased all other code in the body, head and everything else. This is one section of it as an example of what I am doing.</p>

<pre><code>&lt;style type="text/css"&gt;
.centerImage
{
position:absolute;
left: 0px;
bottom: 0px;
width: 100%;
height: 100%;
z-index: 1;
}
&lt;/style&gt;
&lt;script language="JavaScript"&gt;

day=new Date()     //..get the date

x=day.getHours()    //..get the hour

if (x&gt;=0 &amp;&amp; x&lt;1) {
      var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          height: '195',
          width: '260',
          videoId: 'Videolink',
          events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
          }
        });
      }
      function onPlayerReady(event) {
           event.target.setVolume(0);
       event.target.playVideo();
      }
      var done = false;
      function onPlayerStateChange(event) {
        if (event.data == YT.PlayerState.PLAYING &amp;&amp; !done) {
                  done = true;
        }
           event.target.setVolume(2);
      }
   document.write('&lt;div id="player"&gt;&lt;/div&gt;&lt;img src="BG.img" class="centerImage" alt="what image shows" &gt;')
}
&lt;/script&gt; 
</code></pre>

<p>Its launching a video along side of it but that also doesn't work... This is my output</p>

<pre><code>&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div id="player"&gt;&lt;/div&gt;
&lt;img src="BG.img" 
class="centerImage" alt="what image shows"&gt;&lt;/body&gt;&lt;/html&gt;
</code></pre>

<p>Mind you this works just fine in the W3school test platform.</p>