Loading CSS after running PHP Browser detection script
Anybody who can share any idea as to how i can load the CSS for the specific browser detected by the PHP Browser detection script? thanx! ΓΌ
Back to top |
|||||
Get the browser generic name and number, for firefox for example, use the moz identifier, not the 'firefox' one, since all the gecko engines handle css the same across browser versions, netscape, firefox, mozilla, epiphany, etc.
Once you have the browser generic version and version number, the rv version in firefoxes case, you just make a sequence of ifs to load the correct css. :: Code :: if ( $browser == 'op' && $nu > 8 )
{ //load opera > 8 css } elseif ( $browser == 'moz' && $nu > 1.7 ) { //load gecko css, for rv versions > 1.7 } And so on. We don't write people's code for them, but that's the general idea. There are lots of ways to do it, and lots of specific hacks to handle specific stuff in that php detection script, a lot of times you really only need to do one or two detections and then default to standard stuff. For example, I never use msie detections, for several reasons, one of which is that there are a bunch of msie derived browsers, like crazy browser, that do not identify themselves as msie, and use different version numbers. For msie I always use the html conditionals that Microsoft made, those work in all msies, no matter what they are packaged as. And they handle version numbers fine, from 5.0 to the latest. I generally only do custom php based css fixes for safari/khtml, opera, and once in a rare while, firefox/gecko. If you are trying to deliver totally unique stylesheets to each browser type, I SERIOUSLY recommend you rethink your approach now. Usually, I find that no more than a small handful of fixes are required to the overall site css, and usually, most of those are for MSIE 5 and 6, mostly 6. And those are better handled by the conditionals than by scripting. I do, for the sake of validation, include some gecko only, and sometimes safari/khtml only, css, but it's never display critical, just eyecandy stuff, like rounded corners. Back to top |
|||||
Thanks man! but i kinda figured it out myself but i was using the method of detecting msie which you don't use because of msie based browsers. Well, thanks again for giving me the idea of msie based browsers! i'll think of another way to deliver my CSS well using this scripts..thanks man!
Back to top |
|||||
All times are GMT - 8 Hours
|