Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > automatically the right stylesheet

Reply
Thread Tools

automatically the right stylesheet

 
 
picayunish
Guest
Posts: n/a
 
      11-24-2003
Good day all,

I'm trying to make a php function so that the right stylesheet is loaded
for the browser.
What if have is a function for 2 different OS:
<?php if(!eregi('win',$_SERVER['HTTP_USER_AGENT'])){ ?>
<link href="mac.css" rel="stylesheet" type="text/css">
<?php } else { ?>
<link href="windows.css" rel="stylesheet" type="text/css">
<?php } ?>
url is http://www.evandervaart/test2.php

Can I use this function for different browsers?
Or is there another function?
--
Edwin van der Vaart
http://www.semi-conductor.nl/ Links to Semiconductors sites
http://www.evandervaart.nl/ Underconstruction


 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      11-24-2003
picayunish wrote:

> I'm trying to make a php function so that the right stylesheet is loaded
> for the browser.
> What if have is a function for 2 different OS:
> <?php if(!eregi('win',$_SERVER['HTTP_USER_AGENT'])){ ?>


HTTP_USER_AGENT is unreliable at the best of times...

.... and what does the OS have to do with it? AFAIK the _only_ time the OS
has any influence over the rendering of CSS is the differences between
Windows IE and Mac IE.

> Can I use this function for different browsers?


http://www.greytower.net/en/archive/...customcss.html might be of
interest.

--
David Dorward http://dorward.me.uk/
 
Reply With Quote
 
 
 
 
kchayka
Guest
Posts: n/a
 
      11-24-2003
picayunish wrote:

> Good day all,
>
> I'm trying to make a php function so that the right stylesheet is loaded
> for the browser.
> What if have is a function for 2 different OS:
> <?php if(!eregi('win',$_SERVER['HTTP_USER_AGENT'])){ ?>
> <link href="mac.css" rel="stylesheet" type="text/css">
> <?php } else { ?>
> <link href="windows.css" rel="stylesheet" type="text/css">
> <?php } ?>
> url is http://www.evandervaart/test2.php


url is http://www.evandervaart.nl/test2.php

I imagine you'll be getting a bunch of replies on the advisability of
doing such a thing. The usual arguments...

What about other platforms, like linux, OS/2, etc.?

What is it about the platform that is browser agnostic? Mac Safari, Mac
IE, and Mac iCab are all very different. A platform-specific stylesheet
won't do any better than one stylesheet for all versions of Netscape.

> Can I use this function for different browsers?


Why would you want to when there are much more reliable ways to present
different style rules to different browsers? Frankly, I'm surprised you
asked at all. I thought you knew better.

--
To email a reply, remove (dash)un(dash). Mail sent to the un
address is considered spam and automatically deleted.
 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      11-24-2003
David Dorward wrote:

> http://www.greytower.net/en/archive/...customcss.html might be of
> interest.


Although you may find that using good old-fashioned CSS hiding techniques,
such as:

html>body h1 {
color: red; /* IE for Windows won't see this. */
}

.... is more reliable. It solves problems caused by browser spoofing and
caching proxies.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

 
Reply With Quote
 
Leif K-Brooks
Guest
Posts: n/a
 
      11-25-2003
Toby A Inkster wrote:
> Although you may find that using good old-fashioned CSS hiding techniques,
> such as:
>
> html>body h1 {
> color: red; /* IE for Windows won't see this. */
> }
>
> ... is more reliable. It solves problems caused by browser spoofing and
> caching proxies.


But it's more of a hack in another way, because a new version of IE may
add that CSS feature without adding the one you're hiding from it. At
least useragent sniffing will always hide it right.

 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      11-25-2003
Leif K-Brooks wrote:

> But it's more of a hack in another way, because a new version of IE may
> add that CSS feature without adding the one you're hiding from it. At
> least useragent sniffing will always hide it right.


or would be if useragent spoofing wasn't so common.

--
David Dorward http://dorward.me.uk/
 
Reply With Quote
 
Nico Schuyt
Guest
Posts: n/a
 
      11-25-2003
kchayka wrote:
> picayunish wrote:


>> I'm trying to make a php function so that the right stylesheet is
>> loaded for the browser.


> Frankly, I'm surprised you asked at all.
> I thought you knew better.


So am I Must be the effect of a second bottle of Dutch Gin.
Semi, I told you before: no more than *one* bottle! (Like we say in Holland
"A bottle a day keeps the doctor away")
Nico


 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      11-25-2003
Leif K-Brooks wrote:

> Toby A Inkster wrote:
>> Although you may find that using good old-fashioned CSS hiding techniques,
>> such as:
>>
>> html>body h1 {
>> color: red; /* IE for Windows won't see this. */
>> }
>>
>> ... is more reliable. It solves problems caused by browser spoofing and
>> caching proxies.

>
> But it's more of a hack in another way, because a new version of IE may
> add that CSS feature without adding the one you're hiding from it.


Microsoft *may* inprove CSS parsing, but in that case they'll probably
accompany it with improvements to the rest of the CSS engine, possibly
allowing it to properly display what you've hidden from it.

In any case, if Microsoft release a new IE with significant changes in
CSS, you're going to probably have to rewrite parts of your style sheet
anyway.

> At least useragent sniffing will always hide it right.


What about if a new version of IE changes the UA string to:

InternetExplorer/7.0 (Microsoft; Windows NT 5.2)

Will your user agent sniffing get it right then?

User agent sniffing will, as I said earlier, also get it wrong in the case
of browser spoofing. Which of these is really Internet Explorer???

"Mozilla/4.0 (compatible; MSIE 6.0; Windows 9 Opera 7.21 [de]"
"Mozilla/4.0 (compatible; MSIE 6.0; Windows 9"

That's right! Neither! The first is Opera 7.21 and the second is Konqueror
3.1.0.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

 
Reply With Quote
 
Bertilo Wennergren
Guest
Posts: n/a
 
      11-25-2003
Leif K-Brooks:

> Toby A Inkster wrote:


>> Although you may find that using good old-fashioned CSS hiding
>> techniques,
>> such as:
>>
>> html>body h1 {
>> color: red; /* IE for Windows won't see this. */
>> }


>> ... is more reliable. It solves problems caused by browser spoofing and
>> caching proxies.


> But it's more of a hack in another way, because a new version of IE may
> add that CSS feature without adding the one you're hiding from it.


A new version of IE might introduce a number of new bugs that break
things that work now. What can we do?

> At least useragent sniffing will always hide it right.


No. Have you never heard of spoofing and proxies?

--
Bertilo Wennergren <(E-Mail Removed)> <http://www.bertilow.com>

 
Reply With Quote
 
picayunish
Guest
Posts: n/a
 
      11-25-2003
David Dorward wrote:
> picayunish wrote:
>
>> I'm trying to make a php function so that the right stylesheet is loaded
>> for the browser.
>> What if have is a function for 2 different OS:
>> <?php if(!eregi('win',$_SERVER['HTTP_USER_AGENT'])){ ?>

>
> HTTP_USER_AGENT is unreliable at the best of times...
>
> ... and what does the OS have to do with it? AFAIK the _only_ time the OS
> has any influence over the rendering of CSS is the differences between
> Windows IE and Mac IE.


OS hasn't anything to do with HTTP_USER_AGENT.
I only want to know how to use the HTTP_USER_AGENT for different browsers
with the right stylesheet.

>> Can I use this function for different browsers?

>
> http://www.greytower.net/en/archive/...customcss.html might be of
> interest.


Thanx for the link.
--
Edwin van der Vaart
http://www.semi-conductor.nl/ Links to Semiconductors sites
http://www.evandervaart.nl/ Underconstruction


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unsigned right shift casts to int automatically!!! Ehsan Khoddam mohammadi Java 2 01-04-2007 01:30 PM
Firefox and XSLT (local stylesheet works, server-based stylesheet fails) David Blickstein XML 14 10-15-2005 11:27 PM
xml:stylesheet use in document with multiple stylesheet options David Blickstein XML 3 08-02-2005 03:10 PM
have a stylesheet generate another stylesheet based on XML? Steven An XML 1 11-23-2004 01:07 PM
Stylesheet referanse i stylesheet =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?= XML 3 07-04-2004 03:16 PM



Advertisments