开发者

Issue loading selecvizr to <=IE8 only using yepnope (modernizr.load)

I am trying to load selectivizr via yepnope (Modernizr.load) but am having issues with the test command. At the moment I have hacked it using rgba (as that affects <=IE8) but it also affects older Opera and FF browsesrs too, so not ideal (and looks rubbish)

Here is the code:

  <script>
    yepnope.errorTimeout = 2000;
  Modernizr.load([
    {
      load: 'http://ajax.google开发者_运维技巧apis.com/ajax/libs/jquery/1.6.1/jquery.min.js',
      complete: function () {
        if ( !window.jQuery ) {
              Modernizr.load('scripts/jquery-1.6.1.min.js');
        }
      }
    },
        {
            test : Modernizr.mq(),
            nope : 'scripts/respond.min.js'
        },
        {
            test : Modernizr.rgba,
            nope : 'scripts/selectivizr-min.js'
        }
  ]);
  </script>

I know on the selectivizr site it says you should load it like this:

<!--[if (gte IE 6)&(lte IE 8)]>
  <script type="text/javascript" src="selectivizr.js"></script>
<![endif]--> 

But this doesnt work as it gets loaded before jquery finishes.

Also I know there is an ie! Prefix(es) in yepnope but I cant work out where/how to include this file. It seems a pointless to include a 5k if IE file to load a 4k selectizr file.

Any help/guidance appreciated.

A


Just add the conditionals to the beginning of the URL, followed by a !:

<script>
  // yepnope 1.5.4
  yepnope.errorTimeout = 2000;
  Modernizr.load([
    {
      load: 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js',
      complete: function () {
        if ( !window.jQuery ) {
              Modernizr.load('scripts/jquery-1.6.1.min.js');
        }
      }
    },
        {
            test : Modernizr.mq(),
            nope : 'scripts/respond.min.js'
        },
        {
            load : 'iegt5!ielt9!scripts/selectivizr-min.js'
        }
  ]);
</script>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜