![]() |
![]() |
|
|
||
After this system is implemented, any changes you want to make to the site-wide JavaScript code is done by changing only one file. It's an ideal system for site-wide cookie code because the JavaScript can easily be changed as needs change. The idea for this article resulted from the recent TopText, et al, uproar and the need to change every page to block the things. It's probable that other such systems will be developed. Without some system to make site-wide changes, every such intruder could require manually changing every individual page on your site. That can consume many hours, even days if you have large sites. This article shows you how to set it up so you can insert popup windows, remove them, present surveys, change cookie code, and other site-wide functionality in a spontaneous fashion. Once the system is implemented, all you need to do is change one file. This system is ideal for JavaScript code that you want duplicated on every page of your site. It is not for JavaScript that is different on every page or that requires individual placement in pages. The idea is similar to how Master Syndicator works. (See http://willmaster.com/a/11/pl.pl?msyn for info.) The difference is that instead of syndicating content, your file is a depository of JavaScript functions for deployment throughout your site. Implementation Step One Create a plain text file. The top line is: <!-- Create several blank lines, then on the last line put: //--> In between the first and last lines, put the JavaScript code that you want for your entire site. Don't include the <script...> and </script> tags of your JavaScript code. And don't include the individual <!-- and --> HTML comment tags. (Except the one set specified above.) All you need here is the actual JavaScript code. Save the file with a .js file name extension and upload it to your server. Make a note of the file's URL because you'll need it in the next step. Implementation Step Two This step needs to be done only once. In the source code of every page on your site, in the HEAD area, put: <script language="JavaScript" src="http://yourdomain.com/filename.js"> </script> The above code can be all one line, if you want. Just replace http://yourdomain.com/filename.js with the URL to the .js file you uploaded in step one. Once that's done, you're all set. Changing or Adding JavaScript code To change your JavaScript, just change your .js file and upload it. That's it. Slick, huh? Now, when you find new JavaScript you want to use, you can implement it site-wide in minutes instead of hours. Cookie Code Resources The type of JavaScript most requested from us is code related to cookies. At the WillMaster Possibilities ezine site, we have JavaScript code you may modify to suit your needs:
JavaScript cookie code is also available from popular download sites, including http://javascript.internet.com/ A tutorial/how-to article titled "Cookies - In Three Parts" is linked from: http://MasterCGI.com/howtoinfo/ As you can see, site-wide JavaScript implementation is easy to set up. You can start with one or only a few functions and add to the .js file as you go. Actually, the .js file doesn't need any JavaScript functions at all, if you just want to set up the system for future use. This may be a good idea if you're developing a site; you can always add the JavaScript code later. Copyright 2001 William Bontrager
| ||