View Full Version : Add CSS reference to header on the fly

09-08-2005, 08:35 PM

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
<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.

09-09-2005, 11:22 AM
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...

09-09-2005, 11:59 AM
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....

09-09-2005, 01:20 PM
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?

09-10-2005, 08:13 AM
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?