#1
  1. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Posts
    1,882
    Rep Power
    19

    find name of CSS using javascript


    Hi,
    I need to find the name of the attached CSS file in a page by using javascript.

    e.g.
    <link rel="stylesheet" type="text/css href="style1.css" />


    I need the script to find style1.css so that the name can be used later in a document.write script.

    I'm looking into this method because it is an automated way to write the name of CSS, saving me time over many pages..

    Can it be done?
  2. #2
  3. No Profile Picture
    CF sMod
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Maine, USA (a.k.a. Boonies)
    Posts
    242
    Rep Power
    15
    document.getElementsByTagName('link').item(0).getAttribute('href');
    Jason Contact Me
    Super moderator @ CodingForums
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Posts
    1,882
    Rep Power
    19
    cool.


    Is there a way to get the full path to that file?

    e.g.
    For pages I can use document.URL or location.pathname

    At the moment i am using a combination of location.hostname then a string of text.

    e.g.
    var cssURL = location.hostname + '/files/css/'


    Cheers,
    Degs

IMN logo majestic logo threadwatch logo seochat tools logo