Results 1 to 5 of 5

Thread: Add CSS reference to header on the fly

  1. #1
    Join Date
    Jun 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Add CSS reference to header on the fly

    Hello,

    I think that i am screwed, but i wanted to post this question before i kill myself :-)

    we have a site with several thousands of .ASP pages. we are getting ready to implement a new flyout menu. this menu is controlled by a style sheet. the menu is called from an include file (header.inc). each ASP page has it's own
    Code:
    <html><head></head></html>
    tags. i am racking my brain trying to figure out how i can add the reference to the stylesheet without having to add it to each individual page on the site.

    does anyone know of a way that you can add a CCS reference to the HTML HEAD tag on the fly (or at least after the page has rendered)?

    the only thing i could think was to create a thin ISAPI filter that looks for the HEAD tag and inserts the reference....

    thanks in advance for any suggestions.

  2. #2
    Join Date
    Jun 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I would assume that since you are using an include file for the headers then you should not have one for each page - otherwise there would be little to no point.

    So, if this is the case why not use TextPad (or something similar) that has a global find and replace method, i.e. replace all instances in all files.

    Therefore you could have open all of your header.inc files and say replace "</head>" with "<link rel="stylesheet" href="style.css" type="text/css"></head>"

    This should take you all of about, hmm, 20 seconds...

  3. #3
    Join Date
    Jun 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    the header.inc file does not contain the html HEAD tag. it is simply a file that sets up a bunch of session variables and then calls the xml that builds the menu. each ASP page on the site has its own HTML, HEAD, and BODY tag.

    i wish it were only that easy....

  4. #4
    Join Date
    Jun 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i just realized that i can place the style sheet reference outside of the <head> tag and it works fine. is there a downside of not placing the CSS inside the <head> tag?

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    It is invalid, which means it may be unsupported in some current and (possibly all, at some point in time) future browsers. What browser(s) did you test in?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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