admin管理员组

文章数量:1297060

I'm making a website at the moment and for some reason the z-index of a see through overlay is not working in internet explorer (it works in everything else), therefore I want to display a warning message that the website does not support internet explorer, how can I make a div with the class "Warning" show up only in internet explorer?

I am happy to this via any method (HTML, CSS, Jquery etc) as long as it either resolves the z-index issue or makes the warning div show.

Update: I had a friend of mine test my website and the conditional ments don't work in IE11, I want the div to be displayed in all versions of IE.

I'm making a website at the moment and for some reason the z-index of a see through overlay is not working in internet explorer (it works in everything else), therefore I want to display a warning message that the website does not support internet explorer, how can I make a div with the class "Warning" show up only in internet explorer?

I am happy to this via any method (HTML, CSS, Jquery etc) as long as it either resolves the z-index issue or makes the warning div show.

Update: I had a friend of mine test my website and the conditional ments don't work in IE11, I want the div to be displayed in all versions of IE.

Share Improve this question edited Mar 1, 2014 at 0:34 asked Feb 28, 2014 at 0:02 user3186203user3186203
Add a ment  | 

3 Answers 3

Reset to default 6

You can use a conditional statement to show the div:

<!--[if IE]>
    <div class="warning">...</div>
<![endif]-->

This will work for all versions of IE, if you want to target specific versions, see here for more info.

EDIT: As GSerg has pointed out, this will only work for < IE11. For later versions of IE, you may have to rely on some JS like in this Q&A: Browser detection in JavaScript?

Html5 Boilerplate remends this solution (checkout this link for more details):

<!--[if lt IE 8]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy./">upgrade your browser</a> to improve your experience.</p>
<![endif]-->

Wrap your html in a conditional like so:

<!--[if lt IE 7]>[html here]<![endif]-->

the lt means 'less than'. You can target various version of IE by using lt, gt (greater than), lte (less than or equal to) and gte (greater than or equal to).

本文标签: javascriptDisplay div only in IEStack Overflow