开发者

How to show text in IE only

I need to show text on IE only and not show 开发者_如何学运维it for the rest of the browsers. Any pointers to that? I looked around couldn't find it.


Conditional comments.

e.g.

<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->

(There are operators in the condition for less than, less than or equal, ... and you can chain branches to provider different behaviours for different versions see here for full details.)


Please note that since IE 10 conditional commenting are no longer supported and are treated as regular comments:

http://msdn.microsoft.com/en-us/library/ie/hh801214(v=vs.85).aspx

In order for it function as before you need to add the meta tag:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">

There for, for me, if I need to detect IE (although I try to avoid browser detection and use feature detection) I use some code of JS as of here:

Detect IE version (prior to v9) in JavaScript

Best.


You have IE conditional comments or you can do it via javascript detect browser agents or with javascript frameworks such as jQuery

if (jQuery.browser.msie) {
 // do something IE specific
}


Maybe in JS:

<script type="text/javascript">
    function detectBrowser(){
        var browser=navigator.appName;
        if (browser=="Microsoft Internet Explorer"){
            document.write("IE sux");
        }
    }
</script>


The examples here presume you know javascript. It would be nice to see everything you need if you only know HTML.

e.g.

gobbledegook

  • Text I only want IE users to see.
  • moregobbledegook


    You need to detect if current browser is IE and show content only in this case.

    The smallest script for IE detecting:

    if(-[1,]) {
       alert("Not IE!");
    }
    
    0

    上一篇:

    下一篇:

    精彩评论

    暂无评论...
    验证码 换一张
    取 消

    最新问答

    问答排行榜