Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    global use of scripts?

    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.

    thanks!
    trevor

  • #2
    giz
    giz is offline
    Regular Coder
    Join Date
    Apr 2003
    Location
    UK
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    giz
    giz is offline
    Regular Coder
    Join Date
    Apr 2003
    Location
    UK
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks a bunch it works great!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •