zoukankan      html  css  js  c++  java
  • if判断IE浏览器的类型

    有时候需要用到IF判断

    在IE CSS hack(更多方法)当中常用到if IE 来判断浏览器的类型,解决CSS甚至于JS的兼容性问题,之前大家可能知道if IE来解决CSS的兼容性问题,其实if IE不仅仅是用于CSS hack的使用,我们在前端开发中甚至可以使用if IE来做JS的处理,如下面的代码:

    引用<!–[if IE 5]> <script>document.write(”仅IE5.0与IE5.5可以识别”);</script> <![endif]–>

    <!–[if gte IE 5.0]><script>document.write(”IE5.0以及IE5.0以上版本都可以识别”);</script><![endif]–>

    <!–[if IE 6]><script>document.write(”仅IE6可识别”);</script><![endif]–>

    <!–[if lt IE 6]><script>document.write(”IE6以下版本可识别”);</script><![endif]–>

    <!–[if gte IE 6]><script>document.write(”IE6以及IE6以上版本可识别”);</script><![endif]–>

    <!–[if IE 7]><script>document.write(”仅IE7可识别”);</script> <![endif]–>

    <!–[if lt IE 7]><script>document.write(”IE7以下版本可识别”);</script><![endif]–>

    <!–[if gte IE 7]><script>document.write(”IE7以及IE7以上版本可识别”);</script><![endif]–>

    下面对if IE做一下详细的解释:


    lte:就是Less than or equal to的简写,也就是小于或等于的意思。

    lt :就是Less than的简写,也就是小于的意思。

    gte:就是Greater than or equal to的简写,也就是大于或等于的意思。

    gt :就是Greater than的简写,也就是大于的意思。

    ! :就是不等于的意思,跟javascript里的不等于判断符相同

    当然我们也可以使用if IE的注释来引入 js文件,以及CSS hack(更多方法)文件,如下面的代码:

    <!–[if lte IE 6]>
    <!– 如果IE浏览器版本小于等于6,调用ie6.css样式表 –>
    <link rel=”stylesheet” type=”text/css” href=“http://www.js8.in/ie6.css” />
    <![endif]–>

    <!–[if lte IE 6]>
    <!– 如果IE浏览器版本小于等于6,调用ie6.js样式表 –>
    <script type=”text/javascript” src=”http://www.js8.in/ie6.js“></script>
    <![endif]–>

  • 相关阅读:
    Medium | LeetCode 347. 前 K 个高频元素 | 快速排序
    Medium | LeetCode 215. 数组中的第K个最大元素 | 快速排序
    Easy | LeetCode 75. 颜色分类 | 快速排序
    lib和dll
    windows使用cmd打印出当前路径下的所有文件名称
    windows中的sleep和Ubuntu中的sleep
    ‘mutex’ in namespace ‘std’ does not name a type
    gcc命令参数
    ubuntu18.04 使用pthread库
    vs2019 c语言配置pthreads多线程
  • 原文地址:https://www.cnblogs.com/kingwell/p/2555031.html
Copyright © 2011-2022 走看看