Is it possible in Javascript to pass a variable through the src
parameter? ie.
I use the following pattern to convert query variables from to an object containing key:value pairs. Code is placed at the top of script.js:
var getVars = {};
(function(){
var scripts, currentScript, queryString;
scripts = document.getElementsByTagName('script');
currentScript = scripts[ scripts.length - 1 ];
queryString = currentScript.getAttribute('src').split("?").pop().split('&');
for(var i=0;i
This probably won't work with deferred / asynchronously added script elements, as it relies on immediate code execution.