This week's book giveaway is in the Testing forum.
We're giving away four copies of Practical Unit Testing with TestNG and Mockito and have Tomek Kaczanowski on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes How can I determine the browser for CSS purposes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "How can I determine the browser for CSS purposes" Watch "How can I determine the browser for CSS purposes" New topic
Author

How can I determine the browser for CSS purposes

Wilson Mui
Ranch Hand

Joined: Apr 09, 2003
Posts: 140
I would like to determine what broswer the client is running then inmport the appropriate .css file. How can I do that. Can I start a script before I do the <style> header?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
read this:
http://www.thesitewizard.com/css/excludecss.shtml
I have never done this...
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50677

You'd be better off making this decision in server-side code if that's a possibility for you.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Wilson Mui
Ranch Hand

Joined: Apr 09, 2003
Posts: 140
That would be a negative. At least for now.
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 411
I have not tried that, but I am pretty sure you could do something like:
<script>
if(document.all){
document.writeln("<style>........</style>");
}
else{
document.writeln("<style>........</style>");
}
</script>
Gjorgi Var
Ranch Hand

Joined: Feb 24, 2004
Posts: 85
Or Wilson could try this:

Don't forget the last curly brace...
Buena suerte
Gjorgi Var
Ranch Hand

Joined: Feb 24, 2004
Posts: 85
... and almost forgot this: try to avoid loading different css according to user's browser or choice since you'll not be treated well by search engines...
Hasta ma�ana
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
Originally posted by Gjorgi Var:
... and almost forgot this: try to avoid loading different css according to user's browser or choice since you'll not be treated well by search engines...
Hasta ma�ana

Do you have proof of this???
 
 
subject: How can I determine the browser for CSS purposes
 
Threads others viewed
Nested css?
How to determine CSS version used for a page?
Find web application root path?
JSP / CSS
Determing parameters of a service
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture