0

I have written a basic javascript that will show whether or not we are Open/Closed based on our hours. It works great in JS fiddle but when I insert it into my Joomla site using the Jumi module, it is loaded at the very bottom of the page. I'm very new to Javascript so it's likely something incorrectly coded that is causing this problem.

Website: http://askc.org/galacticos/index.php - Scroll to the bottom

<script>
function show_image(src, width, height, alt) {
  var img = document.createElement("img");
    img.src = src;
    img.width = width;
    img.height = height;
    img.alt = alt;
    
    document.body.appendChild(img);
}
    var month = new Date().getMonth();
  var time = new Date().getHours();
  var day = new Date().getDay();

if (month > "3" && month < "10" && day == "6" && time > "19" && time <= "22") {
show_image("http://bizeebee.com/wp-content/uploads/2013/07/open-sign.jpg",500,450, "Powell is OPEN");
}
else { show_image("http://get.whotrades.com/u3/photoBB09/20171363290-0/blogpost.jpeg",500,450, "Powell is CLOSED");}
</script>

Any ideas? Help is much appreciated!

  • where do you want to display that image?as it is below wrapper, it displays at the bottom of the page – Naga Sai A Jul 17 '16 at 22:52
  • Currently I have it sharing a div with the Twitter update feed in the middle of the page, but it's being forced to bottom for some reason. –  Jul 17 '16 at 23:31
  • `document.body.appendChild(img);` - does exactly as you asked - append the image to the body tag. – jpaljasma Jul 17 '16 at 23:45

1 Answers1

0

If you start the function on page load using the window.onload?

window.onload = function () {

show_image(); }

marcollahc
  • 46
  • 1
  • 6
  • I'm thinking that I don't just need to call the function, I need to run my script that will go through the if else statement, which will determine which show_image to call. –  Jul 18 '16 at 04:15