I try to load some js files dynamically,for example:
function openInforWindow(){ //check if the InforWinow.js has been loaded or not if(window.InforWindow){ //do the right thing } else { loadJs('xxxxxx/InforWindow.js'); // do the right thing //but here ,the infowindow is not definded yet. } } function loadJs(filename){ var fileref=document.createElement('script') fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", filename) if (typeof fileref!="undefined") document.getElementsByTagName("head")[0].appendChild(fileref) } How to make sure that the vars or functions in the js which is dynamically loaded can be add to the javascript execute environment so I can use them ?