tinh you are in a bit of a muddle. That if conditional statement you put up earlier works very well in the xhtml . Not the CSS . CSS is not executable.
the only way that the correct stylesheet will show up is if i put style.css under the “else” and “style-ie.css” doesn’t show on FF or IE … any thoughts?
Not many of them. I would recommend, for testing, to do a single if/else:
<?php if (strpos(true == $_SERVER['HTTP_USER_AGENT'],'Gecko')) { ?>
<link rel=stylesheet type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/style.css">
<?php } else { ?>
<link rel=stylesheet type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/style-ie.css">
<?php } ?>
This *should* load style.css in Firefox and current Netscape browsers, and style-ie.css in everything else.
for some reason, with that code, FF is still loading the style-ie.css, and IE is loading style-ie.css also …
I don’t know why that if() test is written like that, and I suspect that’s causing trouble. As I read the code, it’s looking for ‘Gecko’ inside the string returned by the statement true == $_SERVER..., which is going to be “1”, not the actual user agent. I suspect what we’re trying to avoid is the whole problem with strpos returning 0 for “string found at 0th character” vs. strpos returning false for “string not found.” Try this:
<?php if (strpos($_SERVER['HTTP_USER_AGENT'],'Gecko')!==false) { ?><link rel=stylesheet type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/style.css">
<?php } else { ?>
<link rel=stylesheet type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/style-ie.css">
<?php } ?>
Looking it over, I see IC is correct. I’ve been mistakenly misleading you with the code above. Ouch. No excuses.
So either
if(strpos($_SERVER[‘HTTP_USER_AGENT’],’Gecko’)!=false)
or
if(strpos($_SERVER[‘HTTP_USER_AGENT’],’Gecko’)==true)
will work. And sorry about that, tjinh200 .
Very useful info here. Thanks guys!