lorenw — 2013-01-18T16:52:23-05:00 — #1
Hi all, I have this code to work with,
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.
This is within a function and is called when a form is submitted.
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,
logic_ali — 2013-01-18T17:23:25-05:00 — #2
I would guess it's to allow the script to identify the script block that loaded it.
chris_upjohn — 2013-01-19T05:45:42-05:00 — #3
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.