Links to dynamically created (via ColdFusion) CSS

Posted on 2004-11-04
Last Modified: 2013-12-16
I would like to link to a dynamic style sheet created in CF (<link href="CSS.cfm" rel="stylesheet" type="text/css">) (it is being linked on a CF page). I've added <cfcontent type="text/css; charset=ISO-8859-1"> to the css.cfm and the page displays correctly in in IE, Firefox and Netscape, but the stylesheet isn't applied in Opera.

  <cfcontent type="text/css; charset=ISO-8859-1">
 <cfquery name="userSettings" datasource="barney">
     SELECT * FROM userSettings WHERE user=#authenicatedUserID#
<style type="text/css">
     .NormalText {  font-family: <cfoutput>#userSettings.normalFont#</cfoutput>;}

I can make it work in all browsers, by using a cfinclude, but I would prefer to link to the dynamically generated CSS.

How can I get this to work w/ Opera (while still working in IE, Firefox and Netscape) using the link implementation?
Question by:LERNWebmaster
    LVL 30

    Accepted Solution

    > I would prefer to link to the dynamically generated CSS.
    Are you sure about that?
    If you need to dynamically generate the CSS, it might be better to just nest it inside your page.
    Using a linked CSS is good because the client just needs to download it once.
    But it it's dynamically generated, i don't see the point.

    Author Comment

    I would like to re-use the styles in multiple pages, thus using a linked css would allow me to make changes to the one file (it is not 100% dynamic) and have those changes reflected sitewide.  Turns out I had some ColdFusion stuff after setting the contenttype, I moved that to before the <cfcontent> and all is well.
    LVL 30

    Expert Comment

    i'm happy you found a solution.  thanks for the points.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
    This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
    The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now