Forum Moderators: open

Message Too Old, No Replies

Moving javascript from pages to files

         

youfoundjake

9:33 pm on Oct 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Currently, I am using a refer a friend javascript, adsense ads, and my site navigation is javascript with onmouseover events.

What can all be moved to an external javascript file, and for the life of me, how would i reference it in the source code?

londrum

9:37 pm on Oct 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



google doesn't allow you to place their adsense code in an external file, it has to appear on the actual page. so there's not much you can do with that one.

not2easy

3:01 am on Nov 8, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



For the ones you can move, just cut the whole script from the head, edit the tags off the start and end and name it whtever you want to refer to it as, with a .js file extension. Save it to the same directory it will be called from or use a path. Where the script was in the <head>, you can place the tag to call it:
<script type="text/javascript" src="example.js">
</script>
and it will load the same as if it were on the page. If it contains credits, you should leave the credits in the html page where they are. I am sure someone can give you much more (and better) info, I am a rookie but this method works.