...

View Full Version : Loading external JS before page page load (specific span element)



thejackkelly
07-19-2010, 02:29 PM
Hello. My goal is to load the JS for a specific element before displaying that element. I integrated a third part script, and it works well. I set the timer here:

The JS is in my heading as <script type="text/javascript" src="countdownpro.js"></script>

About mid-body I have: <span id="countdown1">2010-07-20 00:00:00 GMT+00:00</span> which allows for the setting of a target date to countdown to.

When the page first loads it shows the above long format target time, until the js/meta tags kick in to modify it to just show the actual countdown as 00:00:00.

I have attached countdownpro.js to this post. I tried shifting the function CD_Init() to the top of the script, and also appended it inline with the .html. I tried setting the big external script to "defer", but neither arrangement worked. I also tried placing the src file right at the top.

I appreciate your help.

RandomUser531
07-19-2010, 05:35 PM
Hello. My goal is to load the JS for a specific element before displaying that element. Is that <span> of any use when JS is not available? If not, style it initially invisible and let the script display it. Otherwise place an inline script block immediately after it to hide it until the timer script loads and can redisplay it.

thejackkelly
07-19-2010, 05:54 PM
Perfect. Thanks x3.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum