Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
How do I load a different stylesheet for IE?
Old 02-27-2007, 05:02 PM How do I load a different stylesheet for IE?
Angelosanto's Avatar
Webmaster Talker

Posts: 548
Name: Danny Angelosanto
Trades: 0
Hi. My games website, http://www.raparcade.com displays fine in Firefox as the stylesheet was made for it. I have a stylesheet for Internet Explorer but how do I detect the users browser and load the relevant stylesheet?

Thanks
__________________
"The only reason some people get lost in thought is because it's unfamiliar territory."
_____________________________________
Angelosanto is offline
Reply With Quote
View Public Profile Visit Angelosanto's homepage!
 
 
Register now for full access!
Old 02-27-2007, 06:00 PM Re: How do I load a different stylesheet for IE?
memberpro's Avatar
Super Talker

Posts: 143
Trades: 0
I know that this is in the Javascript section, but PHP will do this for you... I found a script that you can modify to your needs...

Code:
<?php
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') )
{
  if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') )
  {
$browser = 'Netscape (Gecko/Netscape)';
  }
  else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') )
  {
$browser = 'Mozilla Firefox (Gecko/Firefox)';
  }
  else
  {
$browser = 'Mozilla (Gecko/Mozilla)';
  }
}
else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') )
{
  if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') )
  {
$browser = 'Opera (MSIE/Opera/Compatible)';
  }
  else
  {
$browser = 'Internet Explorer (MSIE/Compatible)';
  }
}
else
{
$browser = 'Others browsers';
}
 
echo $browser;
?>
Just set the style sheet based upon the browser that is detected
__________________

Please login or register to view this content. Registration is FREE
- step-by-step learn how to design, create and install your own website in hours...not days.
Please login or register to view this content. Registration is FREE
was never so easy.
memberpro is offline
Reply With Quote
View Public Profile
 
Old 02-27-2007, 08:02 PM Re: How do I load a different stylesheet for IE?
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Of course, this assumes the web host is capable of reading PHP.

The easy solution is to use conditional comments.
<!--[if lt IE 7]>
call your style sheet here
<![endif]-->Now FireFox will see that as a comment, and ignore it. No server side coding needed.
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 02-27-2007, 10:36 PM Re: How do I load a different stylesheet for IE?
memberpro's Avatar
Super Talker

Posts: 143
Trades: 0
Learn something new everyday.... good solutions Newbie

*** try to give you talkupation, I need to spread some more around first ***
__________________

Please login or register to view this content. Registration is FREE
- step-by-step learn how to design, create and install your own website in hours...not days.
Please login or register to view this content. Registration is FREE
was never so easy.

Last edited by memberpro; 02-27-2007 at 10:38 PM..
memberpro is offline
Reply With Quote
View Public Profile
 
Old 02-28-2007, 09:05 AM Re: How do I load a different stylesheet for IE?
Angelosanto's Avatar
Webmaster Talker

Posts: 548
Name: Danny Angelosanto
Trades: 0
Thanks guys!
__________________
"The only reason some people get lost in thought is because it's unfamiliar territory."
_____________________________________
Angelosanto is offline
Reply With Quote
View Public Profile Visit Angelosanto's homepage!
 
Old 02-28-2007, 09:54 AM Re: How do I load a different stylesheet for IE?
greenlush's Avatar
Ultra Talker

Posts: 481
Name: Jason - Greenlush.com
Location: Bradford, UK
Trades: 0
Quote:
Originally Posted by Learning Newbie View Post
Of course, this assumes the web host is capable of reading PHP.

The easy solution is to use conditional comments.
<!--[if lt IE 7]>
call your style sheet here
<![endif]-->Now FireFox will see that as a comment, and ignore it. No server side coding needed.
This is what we've used for http://www.greenlush.com
greenlush is offline
Reply With Quote
View Public Profile Visit greenlush's homepage!
 
Old 02-28-2007, 03:07 PM Re: How do I load a different stylesheet for IE?
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
There's another advantage to this method than it works on Linux or Windows hosting. It's unmistakably not "cloaking," whereas the other method could be called that. It's not, neither is, but sniffing out the browser on the server side and then sending down an appropriate style sheet is the same technology people use to send one version of their site to humans and a different version to search bots. In Google Webmaster Tools, there's a spot to report another site for cloaking ( and other bad practices ), which is just begging to be abused. Competitor out ranks you, report them for something. Call me paranoid, but the conditional comments seem like insurance against some jerk doing this to you, and some brand-new employee at Google making the wrong call.
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How do I load a different stylesheet for IE?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19708 seconds with 12 queries