문제

I'm wondering if this code works or not:

<!--[if lt IE 8]>
      <script src="/assets/v3/application_ie.js" type="text/javascript"></script>
      <link href="/assets/v3/application_ie.css" media="all" rel="stylesheet" type="text/css" />
    <![endif]-->

I always saw these kind of rules with CSS only, so I'm wondering about javascript here.

도움이 되었습니까?

해결책 2

Yes.

In HTML, anything contained within <!-- ... --> is a comment. Anything contained within this comment block will be treated as a comment and not rendered as HTML (and ultimately not displayed on the page). Older versions of IE will parse through HTML comments looking for its square bracket notation and will render the HTML within if a match is made.

Do note, however, that conditional comments like these are no longer supported in modern versions of IE.

다른 팁

You can have anything you want in a conditional comment.

<!--[if lt IE 8]><p>Update your damn browser!</p><![endif]-->

But you get frowny faces from some people (like me) for having to hax older browsers into working ;) If you need compatibility back there, you should avoid using features that mess up.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top