Simple id question
Hi all, I have this code to work with,
This is within a function and is called when a form is submitted.
var head = $j('head').get(0);
var script = document.createElement('script');
script.src = _tokenScriptSrc+'&num='+_cnt++; // Add uniqueness to the script so we don't get a cached version
So this becomes,
And becomes the last element in the head.
My question is how does "script.id" work into this and where would it go? Am I misunderstanding this?
BTW the script id is defined as var kTokenScriptID = 'TKN'; but why is it needed?
Thanks in advance,
I would guess it's to allow the script to identify the script block that loaded it.
Assigning an ID to a script tag is normally used for tempting libraries such as handlebars so the code within it can be modified or collected on the fly, in your case since you're only executing a script there is no need for it unless its been modified down the track somewhere.