User Name
Password
AppleNova Forums » Programmer's Nook »

Browser specific style sheets


Register Members List Calendar Search FAQ Posting Guidelines
Browser specific style sheets
Thread Tools
EmC
Senior Member
 
Join Date: Jun 2004
Location: Columbus, Georgia
 
2006-02-25, 11:13

I have a web portfolio due for my teaching classes and it is really driving me crazy. It looks fine in Safari, Firefox, and Opera and then I have problems with IE. I know I need to use a separate style sheet for IE, but I can not get it to load. I have php installed on the hosting server and have tried several things found on google. The problem seems to be that there are either no instructions on how to make sure the code is actually working or the instructions are so far over my head that I have to look for an easier solution.
All I want to do is check to see if the browser is IE, if it is load msieportfoliostly.css, if not load portfoliostyle.css. This should be fairly simple right? Why the hell can't I get it to work?

What Adobe Updater‽ What‽ What‽ WHAT‽
  quote
lavieboheme
Member
 
Join Date: Oct 2005
 
2006-02-25, 11:59

Why don't you try using JavaScript to identify the browser and store it as a variable, then (if, then) have it load the IE stylesheet if the browser variable is IE?
  quote
Ryan
Veteran Member
 
Join Date: May 2004
Location: Promise Land of Trustafarians
 
2006-02-25, 12:28

I chose to just put a little message at the top of the page for IE browsers.

http://beniciapantherband.org

I did that using server side includes. I put

Code:
<!--#if expr="${HTTP_USER_AGENT} = /MSIE/" --> <!--#include file="ieMessage.html" --> <!--#endif -->
that code my index file, which calls an HTML file if the browser is IE. It isn't 100% reliable, due to browser spoofing, but I figure users smart enough to know how to use browser spoofing will know that message isn't intended for them.

Last edited by Ryan : 2006-02-25 at 16:39.
  quote
rollercoaster375
Senior Member
 
Join Date: Mar 2005
Location: UIllinois (Champaign, IL)
Send a message via AIM to rollercoaster375 Send a message via MSN to rollercoaster375 Send a message via Yahoo to rollercoaster375 Send a message via Skype™ to rollercoaster375 
2006-02-25, 15:13

Conditional comments pwn (And properly used, they're valid).

Code:
<link rel="stylesheet" type="text/css" href="/css/portfoliostyle.css" /> <!--[if IE]><link rel="stylesheet" type="text/css" href="/css/msieportfoliostly.css" /><![endif]-->
This applies a different stylesheet to IE v.5+... If you plan on supporting IE 4, you'll need to use a server side solution.

Also, the IE CSS will overlap the prior CSS... As such, the IE CSS shouldn't need to be as long.
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2006-02-25, 15:19

What he said: use IE's conditional comments feature. No need for anything server-side at all, nor other sorts of trickery. Microsoft has a thorough explanation here. Make sure you exclude IE 7 from the different stylesheet, as its CSS parser is a lot better.
  quote
EmC
Senior Member
 
Join Date: Jun 2004
Location: Columbus, Georgia
 
2006-02-25, 15:23

Thanks guys. I got it working. The only reason I care at all about IE is that I know that the group that will be grading my web portfolio will be using IE on campus.

What Adobe Updater‽ What‽ What‽ WHAT‽
  quote
ast3r3x
25 chars of wasted space.
 
Join Date: May 2004
Send a message via AIM to ast3r3x  
2006-02-25, 15:31

Does
Code:
<script language="PHP"> //php code </script>
really work?
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2006-02-25, 15:33

Quote:
Originally Posted by ast3r3x
Does
Code:
<script language="PHP"> //php code </script>
really work?
I've never seen or used that before until now. No, it shouldn't work in regular HTML because PHP code cannot be parsed by web browsers. However, if it's placed in a PHP file and parsed by the web server, it should work the same as:

[php]<?php //php code ?>[/php]

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
Ryan
Veteran Member
 
Join Date: May 2004
Location: Promise Land of Trustafarians
 
2006-02-25, 16:38

Quote:
Originally Posted by Brad
I've never seen or used that before until now. No, it shouldn't work in regular HTML because PHP code cannot be parsed by web browsers. However, if it's placed in a PHP file and parsed by the web server, it should work the same as:

[php]<?php //php code ?>[/php]
I just read through that link I posted again and saw that. Oops.
  quote
ast3r3x
25 chars of wasted space.
 
Join Date: May 2004
Send a message via AIM to ast3r3x  
2006-02-25, 19:13

I didn't think that PHP would run like that Brad, but I thought I'd ask. I was wondering if there was a PHP module for apache that would parse that.
  quote
rollercoaster375
Senior Member
 
Join Date: Mar 2005
Location: UIllinois (Champaign, IL)
Send a message via AIM to rollercoaster375 Send a message via MSN to rollercoaster375 Send a message via Yahoo to rollercoaster375 Send a message via Skype™ to rollercoaster375 
2006-02-25, 22:00

Quote:
Originally Posted by ast3r3x
I didn't think that PHP would run like that Brad, but I thought I'd ask. I was wondering if there was a PHP module for apache that would parse that.
Yes, it's standard functionality of PHP - However, most shared hosts turn it off.
  quote
ast3r3x
25 chars of wasted space.
 
Join Date: May 2004
Send a message via AIM to ast3r3x  
2006-02-26, 07:44

Indeed you are right, what do you know. Odd that I've never seen or heard of that before. No reason for that, it's just more typing, and I'd probably more easily confuse it with my HTML.
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools
Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting default browser (without Safari) chriswallace00 Genius Bar 3 2005-09-20 09:17
Silly specific questions from a prospective newbie. Christoph Genius Bar 7 2005-07-21 02:32
New File Browser? Electric Monk Speculation and Rumors 3 2005-06-16 21:53
Browser Launches First? Budgie Genius Bar 1 2005-03-23 15:06


« Previous Thread | Next Thread »

All times are GMT -5. The time now is 12:44.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova