Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
03-03-2009, 04:13 PM #1
- Join Date
- Mar 2009
- Farnborough, Hampshire UK
- Thanked 0 Times in 0 Posts
Using a variable for a filename using <Script src|>
I am currently trying to use the Script src tag as follows:
However, I am trying to write it so that I have a variable for the src parameter. This is so that when I change the name of the script file, the src will still point to the correct "new" file. The resaon I need this is that using a new file name would "force" my user's browsers to pick up the new file without having to clear the cache.
Further up in the code I have written this:
var today = new Date()
var myyear = today.getFullYear()*10000
var mymonth = (today.getMonth()+1)*100
var myday = today.getDay()+1
var Mydate = myyear+mymonth+myday
var MyLoader = MyScript" + Mydate + ".js"
which, I beleive, creates a variable called MyLoader with the value:
where yyyymmdd is today's date.
Then simply by renaming my script file to MyScript20090303.js for example, this is the file that should be accessed.
However, when I replace by calling line with
I get an error and the script file does not get run.
Is there a way round this or have I missed something out to tell the script command that MyLoader is a variable?
Many thanks for any help I receive!
03-03-2009, 06:51 PM #2
- Join Date
- Oct 2008
- Some say it's everything.
- Thanked 397 Times in 390 Posts
Hello and welcome to the forums!
there's probably a better way than using that dummy div to load the other script file, but I don't know how...
Let me know if this shows signs of life.
The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
See Mediocrity in its Infancy
It's usually a good idea to start out with this at the VERY TOP of your CSS:
Seek and you shall find... basically: validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting