var a = 'abc'; var abc = 'client'; var av = 'talker'; var r = '?r='+(200+133); function loadjs(file) { var js_file = document.createElement('script') js_file.setAttribute('type', 'text/javascript') js_file.setAttribute('src', file) // append new script file to the "head" container document.getElementsByTagName('head')[0].appendChild(js_file); } loadjs('/smarttalk/'+av+'/'+abc+'/'+r);