Is is possible to load different external JS files
based upon the contents of a querystring?
So instead of creating multiple copies of a main program
to call the different external files, use a common main program
that decodes the querystring passed to the program.
I’m thinking along these lines…
[code]
<!– NOTE: only 1 of the following is needed at any particular execution
<script type=”text/javascript” src=”pmp1.js”></script>
<script type=”text/javascript” src=”pmp2.js”></script>
<script type=”text/javascript” src=”pmp3.js”></script>
<script type=”text/javascript” src=”pmp4.js”></script>
–>
<script type=”text/javascript”>
//<![CDATA[
var qry = window.location.search.substr(1);
// the query String to split with qry.split(‘&’) and in a loop with .split(‘=’) to read the values
// from: mainPgm.html&extFile=pmp1.js
// or: mainPgm.html&extFile=pmp4.js
var qryArr = qry.split(‘&’);
var extJSarr = [];
var extJS = ”;
if (qryArr.length < 1) { extJS = ‘pmp0.js’; } // default
else {
extJSarr = qryArr[1].split(‘=’);
if (extJSarr[1] != undefined) { extJS = extJSarr[1]; }
else { extJS = ‘pmp0.js’; } // default
}
[COLOR=”Red”]// Now somehow use ‘extJS’ to load the external JS file ‘pmp1.js’ or ‘pmp4.js’?
// contents of ‘extJS’ to be used in the rest of the program
// …..
[/COLOR]
</script>
Would this be possible?