Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

how to handle repeated javascript code in many html files

so that it can be changed later easily

7:34 am on Sep 1, 2009 (gmt 0)

New User

5+ Year Member

joined:Sept 1, 2009
posts: 2
votes: 0

I am going to use several html pages, and there is a javascript code that is being repeated on every page. how can i make it possible that the code may be changed any time easily (just by changing it in one common file).
The code which is being repeated is also javascript code.
12:29 pm on Sept 1, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 22, 2003
votes: 0

Hi lalit

Here is a post that might help explain what you are looking to do... [webmasterworld.com...]



11:15 am on Sept 3, 2009 (gmt 0)

New User

5+ Year Member

joined:Sept 1, 2009
votes: 0

thanx it works.

can you tell me the way if the code is html code instead of jsp should i use document.write or there is better way.

1:52 am on Sept 4, 2009 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
votes: 12

To include JavaScript in many HTML pages, you don't need document.write. Simply include the JavaScript file from each page, as in:

<script type="text/javascript" src="yourjsfile.js"></script>