#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    194
    Rep Power
    13

    Using CSS to post a piece of code...


    I have a large piece of (javascript) code that is posted a few times on the page that I'm creating, so I was wondering if there was a way to put all of this into the CSS file, so that I could simply post it with:

    Code:
    <div id="code">
    Would this be possible?

    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    194
    Rep Power
    13
    Or would it make more sense to use a .js file and if so, how would I go about assigning a word to it and posting the code in the correct place?

    Thanks.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    city of sin, state of the art
    Posts
    421
    Rep Power
    0
    i dont belive you can put javascript into css sheets...

    you can however put them in an external .js file and reference that like...

    Code:
    <script src=externalFileName.js language=JavaScript></script>
    as for placing it where you want it like a css style it kinda depends on the script how you have it set up...

    post some code and i m sure someone could tell ya how you would do that..


    but yea i think an external js would be the best answer..

    good lucky and rock on!!
    "I hate quotations."
    -ralph waldo emerson-
  6. #4
  7. |<.+#f@#+.&.|
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2002
    Location
    norway
    Posts
    3,009
    Rep Power
    1224
    you ought to use
    type="text/javascript" not language="javascript"


    <script src="externalFileName.js" type="text/javascript"></script>

IMN logo majestic logo threadwatch logo seochat tools logo