Aggiungere uno script dopo l'apertura della pagina è un'operazione asincrona. Vuol dire che se scrivi qualcosa come:
non ti funzionerà mai. Devi passare le chiamate alle nuove funzioni attraverso l'evento onload associato al nuovo script. Prova a modificare la tua funzione in questo modo:codice:aggiungiScript("mioscript.js"); eseguiFunzioneNuovoScript();
codice:var JSLOADER = {}; JSLOADER.load = function (jsname, pos, fncCallBack) { var th = document.getElementsByTagName(pos)[0]; var s = document.createElement('script'); s.setAttribute('type','text/javascript'); s.setAttribute('src',jsname); s.onload = fncCallBack; if (!JSLOADER.firstLoaded) { JSLOADER.lastInserted = th.insertBefore(s, document.getElementsByTagName ("script")[0]); JSLOADER.firstLoaded = true; } else { //insertAfter JSLOADER.lastInserted = th.insertBefore (s, JSLOADER.lastInserted.nextSibling); } }; JSLOADER.head = "head"; JSLOADER.body = "body"; JSLOADER.jquery = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"; JSLOADER.jqueryUI = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"; JSLOADER.hoverIntent = "http://cherne.net/brian/resources/jquery.hoverIntent.minified.js"; JSLOADER.firstLoaded = false; JSLOADER.lastInserted = null;

Rispondi quotando