anggapc Posted May 31, 2008 Share Posted May 31, 2008 when i'm trying to include script tag with element innerHTML method , that script couldn't execute. is there another way to load external script?okay, i ask you to the point. i want to include google, adbrite, bidvertiser,etc script dinamically. how to do that? for example, browser load adbrite/adsense every 10 seconds,oranother adsense/adbrite script loaded when i click href link.i'm also try ajax method with this. but it didn't work too.i hope you can help me. thanks. Link to comment Share on other sites More sharing options...
Fukushousha Posted May 31, 2008 Share Posted May 31, 2008 To load an external script saved in a .js file you have to include in the source tag at the top of the page. You can also add it using the onload event.For more information on the onload event go here.If you want it loading when you click an anchor it is easy. Just set it to be executed on the onClick event of the anchor like so:<a ..... onClick="yourfile.js" .....>foo</a> Link to comment Share on other sites More sharing options...
anggapc Posted June 1, 2008 Author Share Posted June 1, 2008 thanks for reply. but your answer can only use for load static javascript file.in this case, i want to load javascript file from javascript code (not in html tag) . it's sounds like "there is a javascript function that load .js file". so, i can load dinamic .js file. Link to comment Share on other sites More sharing options...
vytas Posted June 1, 2008 Share Posted June 1, 2008 Maybe ur looking for something like this: <script type="text/javascript">function dhtmlLoadScript(url){ var e = document.createElement("script"); e.src = url; e.type="text/javascript"; document.getElementsByTagName("head")[0].appendChild(e); }onload = function(){ dhtmlLoadScript("dhtml_way.js");}</script> Link to comment Share on other sites More sharing options...
anggapc Posted June 2, 2008 Author Share Posted June 2, 2008 Maybe ur looking for something like this: <div id="here">change here</div><script type="text/javascript">document.getElementById("here").innerHTML= "<script type=\"text/javascript\">...</script>"; </script> Link to comment Share on other sites More sharing options...
Synook Posted June 2, 2008 Share Posted June 2, 2008 Browsers just don't register it as JavaScript. All they see is text. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.