Jump to content

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


anggapc
 Share

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

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...