View Full Version : global use of scripts?

06-28-2003, 10:47 PM
This might be a no-brainer, but I don't know how to do it. Can you make a file that contains common scripts that every new HTML page can use, like a CSS file? How would you do this? I want to have the same script on every page of my site without adding the code to each page.


06-28-2003, 10:54 PM
External CSS files must not contain any HTML tags or code.

In CSS you must have units with all of your numbers, so one of either px, pt, em, %, or # is always required.

You should export the CSS to an external file and call it with a one line instruction in the <head> section:
<link type="text/css" rel="stylesheet" src="/path/file.css">

Check the resultant file by running it through: http://jigsaw.w3.org/css-validator/validator-uri.html

06-28-2003, 10:59 PM
The answer, above, applies to CSS code (Cascading Style Sheets) only.

The answer below applies only to Javascript files:

Javascript is best done with external .js files, called using:
<script type="text/javascript" language="javascript" src="/path/file.js"></script>

Enclose any inline Javascript code inside this sort of <!-- comment // --> tags, and all of the CSS style code, and any other comments within the HTML part, in this sort of <!-- comment --> tag pair.

Add type="text/javascript" to every <script> tag.

06-28-2003, 11:30 PM
thanks a bunch it works great!