0

我编写了一个基本的 javascript,它将根据我们的时间显示我们是否是开放/关闭的。它在 JS fiddle 中效果很好,但是当我使用 Jumi 模块将它插入我的 Joomla 站点时,它会加载到页面的最底部。我对 Javascript 很陌生,所以很可能是一些错误的编码导致了这个问题。

网站: http ://askc.org/galacticos/index.php - 滚动到底部

<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>

有任何想法吗?非常感谢您的帮助!

4

1 回答 1

0

如果您使用 window.onload 在页面加载时启动该功能?

window.onload = function () {

显示图像();}

于 2016-07-18T00:33:10.390 回答