How to display browser specific HTML?

后端 未结 9 638
遇见更好的自我
遇见更好的自我 2020-12-06 10:48

I\'m trying to find a way to display one link to an IE user and another link to all other browsers using javascript or conditional comments (or whatever it takes).

B

相关标签:
9条回答
  • 2020-12-06 11:41

    This is not going to be the popular answer, but its damn time somebody started posting it - stop with the browser-specific junk. You're only perpetuating future problems when new versions come out.

    If developers had taken the additional time (yes, it takes time and hard work. If you can't convince your clients you aren't trying hard enough) then we wouldn't have seen IE7 "break the web" and there would have been even less of a brouhaha with IE8.

    Yes, IE is less standards compliant than the others. But, Fx is also missing certain things that are a part of the standard too. They all suck when it comes to "standards". But they are all getting better. (At different rates, but they are all getting better.)

    Think first why you are trying to do this, and ask yourself if you really want to deal with this when the next browser version comes out and you have to re-jigger your browser detection and how you handle version X of browser Y.

    [/rant]

    Edit: To answer some of the comments that point out the obvious fact that I didn't really answer the question, without more information this question makes me wonder if we're not trying to help a person decide to hammer in a nail with a glass bottle or a shoe...

    0 讨论(0)
  • 2020-12-06 11:46

    I didn't try, but maybe you could use IE flaws on CSS. Eric Meyer has written this article on the subject: Tricking Browsers and Hiding Styles.

    0 讨论(0)
  • 2020-12-06 11:48

    IE supports conditional compilation, which you can use to easily deliver IE-only code without needing to perform user agent sniffing or feature detection.

    /*@cc_on
       /*@if (@_jscript)
          alert("IE.");
       @else @*/
          alert("Not IE.");
       /*@end
    @*/
    
    0 讨论(0)
提交回复
热议问题