onclick load js file
-
why this is wont work on ie6 1...var html_doc = document.getElementsByTagName('head').item(0); 2...var js = document.createElement('script'); 3...js.setAttribute('language', 'javascript'); 4...js.setAttribute('type', 'text/javascript'); 5...js.setAttribute('src', script_filename); 6...html_doc.appendChild(js); 7...return false; there's no error... and the strange thing is when i add a nalert statement after line 6, it works fine... i need help! :~
Faris Madi Nothing Comes Easy (N.C.E.)
-
why this is wont work on ie6 1...var html_doc = document.getElementsByTagName('head').item(0); 2...var js = document.createElement('script'); 3...js.setAttribute('language', 'javascript'); 4...js.setAttribute('type', 'text/javascript'); 5...js.setAttribute('src', script_filename); 6...html_doc.appendChild(js); 7...return false; there's no error... and the strange thing is when i add a nalert statement after line 6, it works fine... i need help! :~
Faris Madi Nothing Comes Easy (N.C.E.)
-
why this is wont work on ie6 1...var html_doc = document.getElementsByTagName('head').item(0); 2...var js = document.createElement('script'); 3...js.setAttribute('language', 'javascript'); 4...js.setAttribute('type', 'text/javascript'); 5...js.setAttribute('src', script_filename); 6...html_doc.appendChild(js); 7...return false; there's no error... and the strange thing is when i add a nalert statement after line 6, it works fine... i need help! :~
Faris Madi Nothing Comes Easy (N.C.E.)
-
In what way doesn't it work? If an alert at line 6 gets fired then the script element has obviously been added to the DOM succesfully. As above ^^ you probably have to invoke the script some how.
Sorry for not being clear! actually the code is like this function load(script_filename) { var html_doc = document.getElementsByTagName('head').item(0); var js = document.createElement('script'); js.setAttribute('language', 'javascript'); js.setAttribute('type', 'text/javascript'); js.setAttribute('src', script_filename); html_doc.appendChild(js); return false; } and: now, on click the extrnal js file loaded and running fine on firefox, ie7, opera, but not on ie6 in ie6 the js file seems to be trying to load.... when i add the alert after the appendChild statement, the problem disappear and the external js loads. Faris Madi Nothing Comes Easy (N.C.E.)
-
Sorry for not being clear! actually the code is like this function load(script_filename) { var html_doc = document.getElementsByTagName('head').item(0); var js = document.createElement('script'); js.setAttribute('language', 'javascript'); js.setAttribute('type', 'text/javascript'); js.setAttribute('src', script_filename); html_doc.appendChild(js); return false; } and: now, on click the extrnal js file loaded and running fine on firefox, ie7, opera, but not on ie6 in ie6 the js file seems to be trying to load.... when i add the alert after the appendChild statement, the problem disappear and the external js loads. Faris Madi Nothing Comes Easy (N.C.E.)
I'm not a javascript guru, but try these 2 things: try call a function that is in the script you loaded remove the rturn statment.
Brad Australian - Christian Graus on "Best books for VBscript" A big thick one, so you can whack yourself on the head with it.
-
why this is wont work on ie6 1...var html_doc = document.getElementsByTagName('head').item(0); 2...var js = document.createElement('script'); 3...js.setAttribute('language', 'javascript'); 4...js.setAttribute('type', 'text/javascript'); 5...js.setAttribute('src', script_filename); 6...html_doc.appendChild(js); 7...return false; there's no error... and the strange thing is when i add a nalert statement after line 6, it works fine... i need help! :~
Faris Madi Nothing Comes Easy (N.C.E.)
It works; but it depends on what exactly you do next; if you try to access something from that file it wont work because it isn't loaded yet (it loads asynchronously, in a separate thread) You can understand more by reading this articles that details and solves these problems: Challenge-Me: Javascript Including Engine - Part I Challenge-Me: Javascript Including Engine - Part II Challenge-Me: Javascript Including Engine - Part III You can also visit the IncludingEngine site Allex