Jump to content

[please help] why external script can't contain 'script' tag


anggapc

Recommended Posts

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

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

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

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

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

Browsers just don't register it as JavaScript. All they see is text.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...