How To Get Java Code Out Of Your HTML And Still Use It
June 22, 2005
Because most of the Java code used is very simple you don't have to be a programming wizard to get the code off your page and into its own file. Using the code I gave you last week for hiding your email address, let's see how simple it can be.
Here's the code I gave you to hide your email address. I also gave you the instructions on how to modify it and told you to put the code anywhere on your page where you wanted your email address to appear.
user = "username";
site = "yoursite.com";
document.write(user + '@' + site + '
To get this code off your page do the following:
1. Copy the code into a text file and make the changes I mentioned last week.
2. Remove these 2 lines of the code:
3. Save the file with a .js extension (i.e. yourfilename.js). Do not save as .txt or .js.txt ecause that won't work.
4. Every place you want the java code on your site put the following code.
Be sure to change the web address in this line of code to the actual web address of your .js file.
5. Upload your .js file to the location you specified in the above step. See how easy that was?
And if I can do it - So can You.
To Your Success,