简体   繁体   English

无法在页面加载时加载Javascript

[英]Javascript not loading on page load

I have written a basic javascript that will show whether or not we are Open/Closed based on our hours. 我已经写了一个基本的javascript,它将根据我们的小时数来显示我们是否开放。 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. 它在JS小提琴中非常有用,但是当我使用Jumi模块将其插入到Joomla站点中时,它会加载到页面的最底部。 I'm very new to Javascript so it's likely something incorrectly coded that is causing this problem. 我是Java的新手,因此可能是某些编码错误导致此问题。

Website: http://askc.org/galacticos/index.php - Scroll to the bottom 网站: 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> 

Any ideas? 有任何想法吗? Help is much appreciated! 非常感谢帮助!

If you start the function on page load using the window.onload? 如果使用window.onload在页面加载时启动该功能?

window.onload = function () {

show_image(); show_image(); } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM