Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

content type header in css 2

Status
Not open for further replies.

derwent

Programmer
Joined
May 5, 2004
Messages
428
Location
GB
I have set up application mapping in iis to enable a stylesheet to read asp. All works great in IE but FF refuses to read the stylesheet.

In php I can put this at the top of the css to tell FF what to do with the file, is there an asp equivalent?

Code:
<?php header('Content-Type: text/css'); ?>

body {
…
}

…

Thanks folks
 
in between the <head> tags...you can have something like this:

<style type="text/css">
'your css code
</style>

-DNG
 
But I don`t want the css to be printed out with the code of the website, hence referencing the external file.
 
css wont be printed...did you test it...

-DNG
 
I'm confused.

You mean like this?

<style type="text/css">
<link rel='StyleSheet' type='text/css' href='style.css' />
</style>
 
That is what I had matey, but FF just ignores the stylesheet completely because of the application mapping telling it to process it as an asp page.
 
did u try putting the code directly in the page itself instead linking it to a external file..something like this:

<style type="text/css">
TR.row:hover { BACKGROUND-COLOR: #00b2ee }
TR.over TD { BACKGROUND-COLOR: #00b2ee }
</style>

the above is just a sample code...

-DNG
 
It works if I put the css into the page directly but then won`t search engines have to plough through all the css code before it reaches the page content?

The stylesheet is quite large
 
i agree that its not a good idea to put the css code in the page itself if the css content is big...

-DNG
 
yeah, so ideally I need to keep it all in the css file, but FF is ignoring it. I have looked everywhere for an asp equivalent of the php code above, which does the trick if placed at the top of the css file (on php servers of course)
 

I'm assuming you are trying to dynamically generate the CSS ?

If so, then what's with all the Application Mapping. Just output CSS and link to it.

HTML Page:

<html>
<head>
<link rel="stylesheet" type="text/css" href="/mycss.asp" />
<head>
etc..

in the ASP page that generates CSS:
<%
response.Write("p {border: 1px solid #000000;}")
%>
or whatever you had in mind..



A smile is worth a thousand kind words. So smile, it's easy! :-)
 
damber, that works fine in IE but FF doesn`t read the stylesheet at all
 

Works fine for me (v1.5). Post the code you have.

A smile is worth a thousand kind words. So smile, it's easy! :-)
 
If your just wanting to force the ASP file to be treated as having a content type of css, then my guess is that you need to set the type attribute in your link rel tag and possible add in content-type headers in your ASP file:
Code:
Response.AddHeader "content-type:","text/css"

If it still doesn't work after you set the headers and specified the type in your link tag, then my thought would be that you have found abug in FF. Though the fact that it works for damber means that either he is doing something slightly differant or that you might have a less-than-up-to-date version of FF.

barcode_1.gif
 
- sorry, I left out the Response.ContentType setting in my initial post..

It works with OR without this though, as you've already specified the 'type' within the link attributes, so it 'should' respect this... however, set the content type in ASP anyway - as this is more consistent.

My post above should have had this code:
Code:
<%
response.ContentType = "text/css"
response.Write("p {border: 1px solid #000000;}")
%>

But it works with the code I posted initially in IE 6.0, FF 1.5 and Opera 8.51 - so, not sure what you're doing that is different... it is being served from IIS6 (win2003 server) with no customisation on headers or mappings.

The HTML page code:
Code:
<html>
<head>
	<title>title....</title>
	<link rel="stylesheet" type="text/css" href="/test2.asp" />
</head>
<body>
	<p>test</p>
</body>
</html>


Try it out with the code in this post, just in case something in your code is causing issues.

A smile is worth a thousand kind words. So smile, it's easy! :-)
 
Yeah, mine was mis-typed anyways :P I could have sworn I took out that colon and I guess it would have been better to use the built-in Response.ContentType

barcode_1.gif
 
Just noticed that my reply didn`t get posted [neutral] so here's the gist...

I tried dambers test and test2.asp which worked fine. Went back to mine which still didn`t work.

Used the first rule of support and rebooted then my stylesheet now works in FF, woo hoo

Thanks folks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top