Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try changing your Javascript to this:</p> <pre><code>window.onload = function () { // Uncomment this line to make sure the script is loading/running, then delete it // alert('Hello, your Javascript is running'); // Declare variables var currentTime, bannerDiv, newImg; // Get currentTime currentTime = new Date().getHours(); // Get 'banner' div bannerDiv = document.getElementById('banner'); // Get create a new &lt;img&gt; newImg = document.createElement('img'); // Assign a src="" attribute depending on the time newImg.src = (currentTime &gt; 7 &amp;&amp; currentTime &lt; 19) ? 'images/banner_day.jpg' : 'images/banner_night.jpg'; // add the new image to the document bannerDiv.appendChild(newImg); }; </code></pre> <p>And put it in the <code>&lt;head&gt;</code> of the document, so change</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- ....... --&gt; &lt;div id="banner"&gt; &lt;script src="http://beta.adsfasfasfd.com/wp-content/themes/adfadsf/scripts/banner.js"&gt;&lt;/script&gt; &lt;/div&gt; &lt;!-- ....... --&gt; </code></pre> <p>...to:</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;script type="text/javascript" src="http://beta.adsfasfasfd.com/wp-content/themes/adfadsf/scripts/banner.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- ....... --&gt; &lt;div id="banner"&gt;&lt;/div&gt; &lt;!-- ....... --&gt; </code></pre> <p>If it still doesn't work, one of two things is happening:</p> <ul> <li>Your javascript file is not actually at <code>http://beta.adsfasfasfd.com/wp-content/themes/adfadsf/scripts/banner.js</code> so the script cannot be loaded/run. Uncomment the first line to confirm that the script is running.</li> <li>Your banner images cannot be found at <code>images/banner_night.jpg</code> - make sure your relative paths are correct.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload