Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

88 users online



browser detection for different css

browser detection for different css

Currently viewing this thread: 1 (0 members and 1 guests)


Page 2 out of 2
Jeff

Jeff

loves kitties and cuddles
Status: Offline!

Don't use javascript stylesheet detectors, as some people might have javascript turned off, thus circumventing your detection.

I recommend either fixing your code so it's compatible for cross-browser browsing, or use CSS hacks/filters to delegate different CSS rules to different browsers.

See this small article I wrote on what CSS hacks/filters are: http://s91980004.onlinehome.us/articles/cssHacks.php

___________________

I've got a girlfriend! WOOT.

AljapaCo

AljapaCo

online since 96
Status: Offline!
Quote:

Originally posted by Mr.Kill
opera claims that its IE for some reason...dunno why


Press F12 in Opera and you'll get a "fast" menu where you can set the browser to act like IE, NS etc...

Quote:

Originally posted by vek
In opera there is an option to identify itself as internet explorer. don't know why you would want to do that.


Some folks has old websites where they have a code inserted that detects the browser and refuse to show the site if not the surfer is using the "correct" browser. By disgusing Opera as IE you'll work around this problem...

___________________

...a post by Tobias from http://www.alingsasju-jutsu.se/aljapaco.png

MrKill

MrKill

I'm the best and worst at everything !
Status: Offline!
Quote:

Originally posted by AljapaCo
Press F12 in Opera and you'll get a "fast" menu where you can set the browser to act like IE, NS etc...

thats nice, but i dont think everyone who uses opera will all do that... thanks tho

ill try some css hacks then...

___________________

400MB space | 5GB bandwidth | free domain name | PHP/MySQL | $4.95/mo

OMG WHATS THIS?!?!?!?!?

Ynhockey

Ynhockey

Neverside Newbie
Status: Offline!

There is a way to detect Opera with JS using window.opera:

if (window.opera) { USE OPERA STYLESHEET }

As for IE and Mozilla, I don't think you should use browser detection at all. Making a site work in IE, Mozilla and Opera can be a pain, but when you remove Opera out of the picture, it becomes really easy - use the > CSS selector as a hack. It might not be the best way but it works and validates, and doesn't rely on scripting.

___________________

Learn HTML

MrKill

MrKill

I'm the best and worst at everything !
Status: Offline!

the CSS selector? whats that?

i looked at the link iJeff posted and followed some links on there but it scared me so im gonna resort to javascript

besides, the intended audience is web designers, who will have javascript enabled... :P

so wots the javascript? coz dont know it

___________________

400MB space | 5GB bandwidth | free domain name | PHP/MySQL | $4.95/mo

OMG WHATS THIS?!?!?!?!?

Ynhockey

Ynhockey

Neverside Newbie
Status: Offline!

The > selector.

http://www.web-realm.com/guide/?page=css_-_cssch3#opgs

___________________

Learn HTML

freak

freak

Neverside Newbie
Status: Offline!
Quote:

Originally posted by Ynhockey
The > selector.


The '>' selector is know as the child selector.

More can be read about it at the following w3 page http://www.w3.org/TR/CSS21/selector.html#child-selectors

___________________

Tables for layout is an abuse. -- Internet Explorer is unsafe.

webarnes

webarnes

Neverside Newbie
Status: Offline!

here is a list of some tips, tricks, hacks and what not.
http://www.evolt.org/article/Ten_CSS_tricks_you_may_not_know/17/60369/index.html

I am a big fan of clean css.
try to avoid padding when possible.
Definately avoid padding-left: 50px Tongue (just an example)

try to pass your padding up to parent element in form of margin:

.parent{margin:10px 20px;}
.child{font : normal 1.25em Georgia, "Times New Roman", tahoma, Arial, Helvetica, sans-serif; color: rgb(0,0,0); background-color: transparent;}

<h3>Passing the Buck</h3>
<div class="parent">
<p class="child">Pad me Babby!</p>
</div>

William

___________________

http://webarnes.globalwebtech.com/images/zerolarge.gif

Ynhockey

Ynhockey

Neverside Newbie
Status: Offline!

Also avoid using the position attribute when possible. position: absolute makes for a very inflexible layout and position: relative is different in IE / Firefox.

___________________

Learn HTML

Dritz

Dritz

Neverside Newbie
Status: Offline!

As other people have said don't do this but since you insist here is a very simple Javascript that detects a URL and spits out a stylesheet depending on where you are (don't ask why I ever needed this infernal script) which could probably easily be modified to detect browsers:

Code:

<script>
var loc = parent.location.href.toLowerCase;

switch(loc){

case "http://www.yoursite.com/downloads.html":
style="downloads.css";
break;

case "http://www.yoursite.com/forums":
style="forums.css";
break;

case "http://www.yoursite.com/articles.html":
style="articles.css";
break;

default:
style="default.css";

}

document.write("<link rel=\"stylesheet\" href=\"http://www.yoursite.com/" + style + "\">");

</script>

Also note I didn't make this script but unfortunatly I forget who did but it was a user of the forums.

___________________

There I was

Page 2 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0102 seconds.