Tuesday, 12 April 2005

A quick html / js tip (as recorded in my palm's MemoDB)

How to use External Javascripts to keep links etc the same over various pages in a web site

2005-04-12


Create Javascript with appropriate text

function bottom_links()  
{  
document.write('<p>');  
document.write('<a href="#top">Top</a> ');  
document.write('|  ');  
}


Save the file as file.js


Import the JS file into your html file

Type the following into the <head> section of the html file:


<SCRIPT language="JavaScript" SRC="file.js"></SCRIPT>


Call the function somewhere in the html file and the text will be inserted as programmed

<SCRIPT language="JavaScript">bottom_links()</script>


You can now change the links as you like and all the pages where the java is used can show the updated text!!