473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Passing parameters to style sheet, e.g. "mystyle.css?color=ffffff"

How can I pass parameters to a style sheet? I have noticed a couple
of sites are now passing variables to the style sheet, which appear to
be substituted at run time. For example:

<link rel="stylesheet" type="text/css"
href="mystyle.css?color=ffffff">

I have seen references in my temp Internet file directory that
indicates this is possible, but I can't find any documentation how to
do it.

I suspect the mystyle.css page is really an asp or aspx page they does
a substitution with via something like <%=
Request.QueryString("color")%>, but I can't get this to work.

Thanks,

Roger
Jul 21 '05 #1
19 15577

"Roger" <rj*****@viewcentral.com> wrote in message
news:ef**************************@posting.google.c om...
How can I pass parameters to a style sheet? I have noticed a couple
of sites are now passing variables to the style sheet, which appear to
be substituted at run time. For example:

<link rel="stylesheet" type="text/css"
href="mystyle.css?color=ffffff">

I have seen references in my temp Internet file directory that
indicates this is possible, but I can't find any documentation how to
do it.

I suspect the mystyle.css page is really an asp or aspx page they does
a substitution with via something like <%=
Request.QueryString("color")%>, but I can't get this to work.


I'd think it would have to be that. But then you'd need to configure your
web site to treat requests with the .CSS extension as ASP(X) requests, and
would need to add

<% Response.ContentType = "text/css" %>

at the top of the CSS file. Alternatively you could skip the .CSS extension,
and have

href="mystyle.asp?color=#ffffff"

Then you could skip the server configuration part and just set the content
type and rename mystyle.css to mystyle.asp.
Jul 21 '05 #2
Thanks Harlan. Simply using an .asp page instead of a .css page allows
the query string process and appears to work, at least under IE 6.

Do you think any browsers are sensitive to the .css extension, or
should all browswers access any style sheet reference, as long as the
reference in the html file is correct and the style sheet has the
correct syntax?

Thanks again,

Roger

Jul 21 '05 #3

<rj*****@viewcentral.com> wrote in message
news:10*********************@c13g2000cwb.googlegro ups.com...
Thanks Harlan. Simply using an .asp page instead of a .css page allows
the query string process and appears to work, at least under IE 6.

Do you think any browsers are sensitive to the .css extension, or
should all browswers access any style sheet reference, as long as the
reference in the html file is correct and the style sheet has the
correct syntax?


The latter. All the browser does is send a request for the named resource
back to the server verbatim. The same technique works for dynamically
generating images, by putting the URL for an image-generating ASP file in
the SRC attribute of an IMG tag.

Jul 21 '05 #4
Harlan Messinger wrote:
<rj*****@viewcentral.com> wrote in message
news:10*********************@c13g2000cwb.googlegro ups.com...
Thanks Harlan. Simply using an .asp page instead of a .css page allows
the query string process and appears to work, at least under IE 6.

Do you think any browsers are sensitive to the .css extension, or
should all browswers access any style sheet reference, as long as the
reference in the html file is correct and the style sheet has the
correct syntax?

The latter. All the browser does is send a request for the named resource
back to the server verbatim. The same technique works for dynamically
generating images, by putting the URL for an image-generating ASP file in
the SRC attribute of an IMG tag.

yes, It Works (tm) but is it The Right Way (tm)

--
-----------------------------------------
Visit my site! http://solid.bounceme.net
-----------------------------------------
Jul 21 '05 #5
StarQuake <st*******@antispam.tiscali.nl>:
| href="mystyle.asp?color=#ffffff"
yes, It Works (tm) but is it The Right Way (tm)


On the web file extensions are meaningless, MIME types count. (IE
sometimes thinks it knows better, though.) In URLs you should not mention
your serverside technonlogies, so .php, .asp etc should, if at all, only
occur if it is a link to the non-interpreted source.

--
No sig today, my .sig has gone away
The divider stands forlorn, a symbol of the dawn
No sig today, it seems a common sight
But people reading by don't know the reason why
Jul 21 '05 #6
rj*****@viewcentral.com wrote:
Thanks Harlan.
For what? Please include a bit (but not all) of the message you're
replying to so that we have some context.
Simply using an .asp page instead of a .css page allows the query
string process and appears to work, at least under IE 6.

Do you think any browsers are sensitive to the .css extension,
In a www client (e.g., a web browser), there is no file extension, only
a url and a mime type to tell the client what kind of resource it is.
should all browswers access any style sheet reference, as long as the
reference in the html file is correct and the style sheet has the
correct syntax?


They should all do it, and most do. MSIE/Win -- which is not really a
browser, but sort of acts like one at times -- violates the standard by
ignoring the mime type in favor of content sniffing. MS claims that the
latest "security" [1] pack fixes this, but appears to introduce other
broken stuff to replace what they've fixed. In particular, they advise
web authors to use the correct file extension for web resources. That's
utter nonsense on the client end; as I said above, there is no file
extension to interpret.

Note that some versions of Firefox and Opera have begun to copy
MSIE/Win's broken behavior with regard to css, overriding text/plain and
treating it as css if that's what it appears to be.
[1] It's hard to use "MS" and "security" in the same sentence without
falling off my chair in hysterical laughter.

--
Brian (remove "invalid" to email me)
Jul 21 '05 #7
Brian <us*****@julietremblay.com.invalid>:

MSIE/Win (...) violates the standard by
ignoring the mime type in favor of content sniffing.


Actually IE doesn't ignore the MIME type completely, but uses it as just a
minor type indicator. Sad enough.

--
"Space may be the final frontier,
but it's made in a Hollywood basement."

Red Hot Chili Peppers - Californication
Jul 21 '05 #8

"StarQuake" <st*******@antispam.tiscali.nl> wrote in message
news:2t*************@uni-berlin.de...
Harlan Messinger wrote:
<rj*****@viewcentral.com> wrote in message
news:10*********************@c13g2000cwb.googlegro ups.com...
Thanks Harlan. Simply using an .asp page instead of a .css page allows
the query string process and appears to work, at least under IE 6.

Do you think any browsers are sensitive to the .css extension, or
should all browswers access any style sheet reference, as long as the
reference in the html file is correct and the style sheet has the
correct syntax?

The latter. All the browser does is send a request for the named resource back to the server verbatim. The same technique works for dynamically
generating images, by putting the URL for an image-generating ASP file in the SRC attribute of an IMG tag.

yes, It Works (tm) but is it The Right Way (tm)


Absolutely. It's a URL, there's no restriction on what kind of URL it is,
and there's *no reason* why the browser should pre-inspect it. It's none of
the browser's business.

Jul 21 '05 #9
On Wed, 20 Oct 2004, Christoph Paeper wrote:
Brian <us*****@julietremblay.com.invalid>:

MSIE/Win (...) violates the standard by
ignoring the mime type in favor of content sniffing.


Actually IE doesn't ignore the MIME type completely,


Prior to XP SP2, MS documents its violation of the mandatory HTTP
requirements for a specific list of 26 MIME types, although it hints
that it reserves the right to compromise other MIME types too, if and
when it feels like it.

http://msdn.microsoft.com/workshop/n...appendix_a.asp

Indeed when I tried it back then (in NT4) it did indeed behave as
documented. If you chose some preposterous MIME type which MS hadn't
yet heard of, you could associate it with an appropriate helper
application, and, under these limited conditions, IE would give a
remarkable impression of being a WWW browser. For example, I told
MSIE that it should open documents of type application/xhtml+xml by
using Mozilla. This worked fine: behind the scenes, IE saves the data
to a temporary file, and then fires up Mozilla to open the document
from its temporary file location.

I have some discussion at
http://ppewww.ph.gla.ac.uk/~flavell/...tent-type.html

But surely you're going to ask why not browse the web using Mozilla in
the first place, and I could only agree. I basically reserve IE for
visits to Windows Update these days.

It's clear that in XP SP2 they haven't actually solved the problem
that they had created before; but they seem to have introduced a new
bunch of brokenness. I haven't seen any clear documentation yet of
what they claim to have done. Just the usual anodyne woffle that MS
knows best what the user wants (and by implication that the IETF
couldn't tell a security exposure from a hole in the ground. It would
be funny if it wasn't so serious.)
Jul 21 '05 #10
Brian wrote:
MS claims that the latest "security" [1] pack fixes this


That should be "service pack". So, as it turns out, I don't need to use
"security" and "MS" in the same sentence. ;-)

--
Brian (remove "invalid" to email me)
Jul 21 '05 #11
Christoph Paeper wrote:
Brian:

MSIE/Win (...) violates the standard by ignoring the mime type in
favor of content sniffing.

Actually IE doesn't ignore the MIME type completely, but uses it as
just a minor type indicator.

Before SP2, MSIE *ignored* the MIME type entirely, unless other methods
(such as content sniffing) failed.

--
Brian (remove "invalid" to email me)
Jul 21 '05 #12
On Wed, 20 Oct 2004, Brian wrote:
Before SP2, MSIE *ignored* the MIME type entirely,
That's not correct - it's worse than that: they actually /tested/ the
MIME type against a list of 26 MIME types before deciding to ignore
it. Any remaining MIME types not on that list were (with some bizarre
exceptions related to plugins) handled correctly (including, just to
rub salt into the wound, content types like application/msword,
application/vnd.ms-excel - even text/rtf was not in their hitlist for
this IETF-violating behaviour).

So, far from "ignoring" the MIME type, they took a close look at it
before deciding to violate the interworking mandates by tossing it
aside.
unless other methods (such as content sniffing) failed.


Not that either: if content sniffing failed, their last resort still
didn't involve the original MIME type (for the dread 26 types on their
hit list). Sometimes, however, it involved what they interpreted as
the filename extension (which of course for HTTP is defined by the RFC
to be irrelevant when there's a MIME type present - which means
essentially "all of the time" nowadays).
Jul 21 '05 #13
Unfortunately, using an asp page for a style sheet does not appear to
work for FireFox v 1.0. If I attempt to reference the style sheet as
<link rel="stylesheet" type="text/css" href="mystyle.asp"> it does not
pick up the style sheet. However, the reference <link rel="stylesheet"
type="text/css" href="mystyle.css"> works fine. Both of these work
fine with IE.

It appears IE does not seem to care what the extension is for the style
sheet, but FireFox does.

Roger

Jul 21 '05 #14
<rj*****@viewcentral.com> wrote:
Unfortunately, using an asp page for a style sheet does not appear to
work for FireFox v 1.0. If I attempt to reference the style sheet as
<link rel="stylesheet" type="text/css" href="mystyle.asp"> it does not
pick up the style sheet. However, the reference <link rel="stylesheet"
type="text/css" href="mystyle.css"> works fine. Both of these work
fine with IE.

It appears IE does not seem to care what the extension is for the style
sheet, but FireFox does.


The problem isn't ASP per se, nor is it the .asp filename extension. The
problem is almost certainly that "mystyle.asp" is being sent with the wrong
MIME type.

See http://css.nu/faq/ciwas-aFAQ.html#QA05
--
Darin McGrew, mc****@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp.com, http://www.HTMLHelp.com/

"It's easier to stay out than to get out." - Mark Twain
Jul 21 '05 #15
rj*****@viewcentral.com wrote:
Thanks Harlan. Simply using an .asp page instead of a .css page
allows the query string process and appears to work, at least under
IE 6.

Do you think any browsers are sensitive to the .css extension, or
should all browswers access any style sheet reference, as long as the
reference in the html file is correct and the style sheet has the
correct syntax?

Thanks again,

Roger


Mozilla (I think) doesn't pick up that a .php/.asp file contains css data
unless you send it with "Content-Type:text/css"
Jul 21 '05 #16
rj*****@viewcentral.com wrote:
Unfortunately, using an asp page for a style sheet does not appear to
work for FireFox v 1.0. If I attempt to reference the style sheet
as <link rel="stylesheet" type="text/css" href="mystyle.asp"> it does
not pick up the style sheet.
Url? I imagine that the stylesheet is sent with the wrong MIME type.
Fix that and it will work in Firefox.
However, the reference <link rel="stylesheet" type="text/css"
href="mystyle.css"> works fine.
Firefox mimics IE in a small subset of cases, where the resource is
likely to be css. I think the MIME type sent with the resource must be
text/plain as well in order to trigger Firefox's guessing mechanism, but
I can't be sure in light of what you've reported. Furthermore, it
appears that the resource url must end in ".css", though I can't be sure
without a url to test.
Both of these work fine with IE.
Of course. It sniffs content in any case, but only for certain MIME
types as A. Flavell explained. See his post of 20 Oct 2004 for his
remarks, including a correction of what I wrote earlier.
It appears IE does not seem to care what the extension is for the
style sheet
First, let's be clear: there is no extension on the www. There is a
resource and its url. That's it. File names, including extensions, are
only applicable on a filesystem.
but FireFox does.


Only where it chooses to try to guess the type, and only in certain
versions, and only for css. There was a time when Mozilla obeyed the
relevant standards entirely, and never tried to second guess the MIME
header. Alas, it, along with Opera, have followed IE, no doubt in an
attempt to make it appear that their browsers "work" when in fact, in
this matter, they are all broken.

--
Brian (remove "invalid" to email me)
Jul 21 '05 #17
Alan J. Flavell wrote:
On Wed, 20 Oct 2004, Brian wrote:

Before SP2, MSIE *ignored* the MIME type entirely,

That's not correct - it's worse than that: they actually /tested/ the
MIME type against a list of 26 MIME types before deciding to ignore
it.


I forgot about that part. Thanks for the correction.
Any remaining MIME types not on that list were (with some bizarre
exceptions related to plugins) handled correctly (including, just to
rub salt into the wound, content types like application/msword,
application/vnd.ms-excel -
That is just plain rediculous. application/msword can be trusted, but
text/plain cannot? Sheesh.
So, far from "ignoring" the MIME type, they took a close look at it
before deciding to violate the interworking mandates by tossing it
aside.
Right. I was thinking of this behavior of tossing the MIME type aside
when I wrote "ignore", but your explanation is clearer.
unless other methods (such as content sniffing) failed.

Not that either: if content sniffing failed, their last resort still
didn't involve the original MIME type


Perhaps my memory fails me. I thought that using the MIME type header
was on their list of things to use when content sniffing failed. But I
cannot read mail or surf the web easily from my laptop computer, where I
bookmarked the MS documentation of this behavior, so I cannot check it.
Sometimes, however, it involved what they interpreted as the filename
extension


I thought that was actually *below* MIME type, which was itself below
(by several steps) content sniffing. Again, I'm working from memory,
which isn't (apparently!) what it used to be.

In any case, the change in SP 2 seems to have reemphasized the
importance of file extension, with no clear definition of extension on
the www. Ho hum.

--
Brian (remove "invalid" to email me)
Jul 21 '05 #18
Brian <us*****@julietremblay.com.invalid> wrote:
Only where it chooses to try to guess the type, and only in certain
versions, and only for css. There was a time when Mozilla obeyed the
relevant standards entirely, and never tried to second guess the MIME
header. Alas, it, along with Opera, have followed IE, no doubt in an
attempt to make it appear that their browsers "work" when in fact, in
this matter, they are all broken.


It's a GUI pref option in Opera, I assume that Firefox can also be made
to behave.

--
Spartanicus
Jul 21 '05 #19
On Thu, 21 Oct 2004, Brian wrote:
Alan J. Flavell wrote:
On Wed, 20 Oct 2004, Brian wrote:
unless other methods (such as content sniffing) failed.


Not that either: if content sniffing failed, their last resort still
didn't involve the original MIME type


Perhaps my memory fails me.


I think the fault was mine, sorry.

http://msdn.microsoft.com/workshop/n...appendix_a.asp

Their literally "last" resort (step 6) doesn't actually involve
the server-provided MIME type at all. But some of the earlier steps
-do- involve some assessment of (rather than total disregard of) the
server-provided MIME type, and I'd forgotten that.
I thought that using the MIME type header
was on their list of things to use when content sniffing failed.
Steps 3, 4, and 5 as described in their woffle seem to be complicated,
even assuming that they accurately reflect what happens. You're right
that the server-provided MIME header is still being used for some
purposes within these steps. Step 2 is the one where the MIME type,
having been inspected and found to be on their hit-list, is then
disregarded "if one of the hard-coded [content-sniffing] tests
succeeded".
In any case, the change in SP 2 seems to have reemphasized the
importance of file extension, with no clear definition of extension
on the www. Ho hum.


Indeed. No wonder that they also fall foul of these virus
attachments[1] with file names like "document.txt
..scr"

sigh.
[1] "attackments" is perhaps le typo juste.
Jul 21 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ckroom | last post by:
Hi, I have a vector of chars: "FFFFFF" Each 2 chars from the vector in hex represents a decimal number, how can I convert the vector to 3 decimal values (char *)"FF"->(int)256. I have no idea. ...
22
by: Alan Silver | last post by:
Hello, I am updating some old web pages, and have come across a problem. I have some tables where the opening tag looks like... <table border="1" bordercolor="#ffffff"> which gives a nice...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.