• i remember that there is a way, in your stylesheet to specify IE and Mozilla and what to do for either instance, but i can’t seem to remember … is there a good way to ensure cross-browser compatibility? (using px, pt, em, % is not working) …

Viewing 7 replies - 16 through 22 (of 22 total)
  • 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.

    Thread Starter tjinh200

    (@tjinh200)

    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.

    Thread Starter tjinh200

    (@tjinh200)

    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!

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘cross-browser CSS question’ is closed to new replies.