hi soonkhoo,
may be smth like this?
<script>
var ii=Math.floor(Math.random()*10)
var string
switch (ii){
case 0:{ string='file0.js' ; break}
case 1:{ string='file1.js' ; break}
case 2:{ string='file2.js' ; break}
case 3:{ string='file3.js' ; break}
case 4:{ string='file4.js' ; break}
case 5:{ string='file5.js' ; break}
case 6:{ string='file6.js' ; break}
case 7:{ string='file7.js' ; break}
case 8:{ string='file8.js' ; break}
case 9:{ string='file9.js' ; break}
default : break
}
document.write('<'+'script language="javascript" src="'+string+'">'+'</'+'script>')
</script>
Thanks!! But can you explain to me how do you call the script or run it for there's no function. Does that mean I need to insert it in the body tag? Thanks.
hi again
it's just a example, but it does what u want 2 do (at least it includes dfrnt js files randomly)
it is advised 2 place scripts into head section, then it wuld include file just in the process of page generation;
'coz if u wuld make a function with such code & call it whenever after page have been generated - document.write wuld overwrite the hole page, & ur document wuld be gone..
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.