Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Closed Thread
Old 12-05-2010, 05:03 PM Javascript include
DIY
Experienced Talker

Posts: 35
Trades: 0
I currently have a site with about 500+ static pages, some of which are in directories etc. so changing a line of code on each page is a real nightmare.

On most of the pages I have an affiliate banner at the bottom, which appears by me inserting this code in the bottom of each page in the source code

Code:
<script language="javascript" type="text/javascript" 
  src="http://www.mysite.co.uk/ban.txt"></script>
Then on the server I have a text file called ban.txt and in that text file I have the affiliate code which is javascript.

I'd like to replace the affiliate code with a 728*90 banner and link to a friends site, but I have no idea how to do it without replacing the line of code on every page of my site.

Hopefully someone will know how to do it by just changing the code in the ban.txt file?

Any help would be appreciated
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
DIY is offline
View Public Profile
 
 
Register now for full access!
Old 12-05-2010, 05:14 PM Re: Javascript include
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
If you want a javascript function to execute (run) it will have to be in a .js file NOT a .txt file.

Other than that you will have to use server side includes.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Old 12-05-2010, 05:23 PM Re: Javascript include
DIY
Experienced Talker

Posts: 35
Trades: 0
Thanks for the fast reply Chris

It works at the moment as a txt file
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
DIY is offline
View Public Profile
 
Old 12-05-2010, 10:10 PM Re: Javascript include
Super Spam Talker

Posts: 878
Name: Paul W
Trades: 0
On some setups the .js extension is important and it's a good habit anyway, to distinguish from ordinary text files.Assuming the page HTML doesn't "get in the way", just replace the contents of ban.txt with the appropriate document.writes to get the output you want.I'd create ban.js and try it on a test page, then do a global replace to change from ban.txt
PaulW is offline
View Public Profile
 
Old 12-06-2010, 05:18 AM Re: Javascript include
DIY
Experienced Talker

Posts: 35
Trades: 0
I have sorted it thanks!

The line I used to include the javascript was originally used for a banner rotator, so I have just made the rotator use one image and one url, which still works with the .txt file.

Thanks for the replies
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
DIY is offline
View Public Profile
 
Closed Thread     « Reply to Javascript include
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25419 seconds with 12 queries