2012-10-15 2 views
4

저는 Modernizr 2.6.2를 개발중인 사이트에서 사용하고 있으며 IE8에서 좌절감을 느끼고 있습니다. 나는 문서의 머리 모더 나이저를로드 해요 :IE8 및 Modernizr : 개체가이 속성 또는 메서드를 지원하지 않습니까?

<script src="js/vendor/modernizr-2.6.0-ck.js"></script> 

그럼 난 그냥 닫는 </body> 태그 바로 앞에 페이지의 하단에 base.js 파일을로드하고 있습니다. 단지 Object doesn't support this property or method 말,

/** 
* Non-jQuery hasClass function for checking the existence of 
* class names on elements. 
* @param {string} scripts The string of scripts to check 
* @param {string} cls The class name we're looking for 
* @return {boolean} True or false 
*/ 
/* 
function hasClass(scripts, cls) { 
    var r = new RegExp('\\b' + cls + '\\b'); 
    return r.test(scripts); 
}*/ 


/** 
* Get ID from <body> tag 
*/ 
function matchBodyID(match) { 
    return match.toLowerCase() === document.body.id.toLowerCase(); 
} 


/** 
* Check to see if the body tag has a "data-scripts" attribute. 
* If true, collect the contents. If false, set to false. 
*/ 
// var dataScripts = document.body.getAttribute("data-scripts") || false; 


/** 
* Variables must be defined before we can use them. 
*/ 
var Modernizr = Modernizr || {}, 
    ScaleText = ScaleText || {}; 


/* 
* Using Modernizr.load, we can run our tests to see 
* which features are available to us and load our 
* polyfills to handle those that aren't 
*/ 
var timestamp = new Date().getTime(); 
Modernizr.load([ 
    { 
     load: [ 
      '//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js', 
      'js/plugins/image-array-ck.js?t=' + timestamp, 
      'js/plugins/jquery.debouncedresize-ck.js', 
      'js/plugins/menu-ck.js?t=' + timestamp 
     ], 
     complete: function() { 
      if (!window.jQuery) { 
       Modernizr.load('js/vendor/jquery-1.8.1.min.js'); 
      } 
      ScaleText.invoke(); 
      $("#skip-to-content").bind("click.menu", function (event) { 
       event.preventDefault(); 
       var $this = $(this), 
       $par = $($this.parent()); 
       $par.toggleClass("open"); 
      }); 
     } 
    }, { 
     test: matchBodyID('home') || matchBodyID('department'), 
     yep: [ 
      'js/plugins/spin.min.js', 
      'js/slideshow-ck.js', 
      'css/royalslider/royalslider.css', 
      'css/royalslider/rs-minimal-white.css', 
      'js/plugins/tabs-ck.js?t=' + timestamp, 
      'js/plugins/underscore-min.js' 
     ] 
    }, { 
     test: matchBodyID('interior'), 
     yep: [ 
      'js/plugins/spin.min.js', 
      'js/plugins/tabs-ck.js?t=' + timestamp, 
      // 'js/plugins/menu-ck.js?t=' + timestamp, 
      'js/plugins/underscore-min.js' 
     ] 
    }, 
    // Check for iOS 
    { 
     test: Modernizr.appleios, 
     yep: [ 
      'js/plugins/ios-ck.js' 
     ] 
    }, 
    // Functional polyfills 
    { 
     test: Modernizr.flexbox, 
     nope: ['js/polyfills/flexie.js'] 
    } 
]); 




/* 
* ScaleText 
* An attempt to create a custom type scaler for 
* large type that needs to scale to fit its parent 
*/ 
ScaleText = { 

    invoke: function() { 
     $(".scalable").each(function (index, element) { 
      var $parent = $(element), 
       $wrapper = ScaleText.wrapIt($parent.first("div")); 

      $parent.css({ 
       "overflow": "hidden", 
       "opacity": 0 
      }); 
      $wrapper.css({ 
       "-webkit-transform-origin": "left top", 
       "-moz-transform-origin": "left top", 
       "-ms-transform-origin": "left top", 
       "-o-transform-origin": "left top", 
       "transform-origin": "left top" 
      }); 
      ScaleText.checkSize($parent, $wrapper); 

      jQuery(window).on("debouncedresize.ScaleText", function() { 
       ScaleText.checkSize($parent, $wrapper); 
      }); 
     }); 
    }, 

    checkSize: function ($parent, $wrapper) { 
     var scrollWidth = $parent[0].scrollWidth, 
      width = $parent.width(), 
      scrollHeight = $parent[0].scrollHeight, 
      height = $parent.height(), 
      ratio, wRatio, hRatio; 

     wRatio = width/scrollWidth; 
     hRatio = height/scrollHeight; 
     ratio = (wRatio < hRatio) ? wRatio : hRatio; 

     $wrapper.css({ 
      "-webkit-transform": "scale(" + ratio + ")", 
      "-moz-transform": "scale(" + ratio + ")", 
      "-ms-transform": "scale(" + ratio + ")", 
      "-o-transform": "scale(" + ratio + ")", 
      "transform": "scale(" + ratio + ")" 
     }); 
     $parent.css({ 
      "opacity": 1 
     }); 
    }, 

    wrapIt: function (element) { 
     var content = $(element).html(), 
      $wrapper = $("<div>" + content + "</div>"); 
     $(element).empty().append($wrapper); 
     return $wrapper; 
    } 

}; 

IE8 완전히 Modernizr.load 블록에 질식 몇 가지 이유 : 그 base.js 파일에서 다음 코드 (Hastebin link for readability)가 있습니다. 스크린 샷 첨부.

왜 이런 일이 일어날 지 생각해보십시오.

편집

나는 모더 나이저의 사용자 지정 빌드를 사용하고 언급해야한다 : enter image description here

+0

이 작업을 수행 했습니까? 아주 똑같은 시나리오와 문제를 방금 넘었습니다. –

+0

동일한 문제가 있습니다. – cbaigorri

+0

IE9에서 같은 문제가 발생합니다. – ximi

답변

1

http://www.hastebin.com/fitaqireha.coffee

내가 너무이 있어요. Modernizr.load()는 선택 사항입니다. 다음은 modernizr-2.5.3의 헤더에서 나온 것입니다.

/*  
* Modernizr has an optional (not included) conditional resource loader 
* called Modernizr.load(), based on Yepnope.js (yepnopejs.com). 
* To get a build that includes Modernizr.load(), as well as choosing 
* which tests to include, go to www.modernizr.com/download/ 
*/ 
당신은 here에 가서 패키지를 다시 얻을해야합니다

- 추가 범주에 에게 Modernizr.load을 확인하십시오. 그러면 파일 끝에 yepnopejs가 포함됩니다.

This 무엇이 추가 되었습니까? 기존의 modernizr. * .js에 고정되어 있으며 모두 예상대로 작동합니다.

0

IE8 (Chrome에는 없지만)과 동일한 "개체가이 속성 또는 메서드를 지원하지 않습니다."라는 오류가 발생했습니다.

동일한 Modernizr 선언 스크립트를 참조하는 다른 페이지가 있었기 때문에 다른 곳에서 문제가 발생한 것으로 생각됩니다. 내가로드 블록에 추가 쉼표 있었다 밝혀졌다 : 나는 비주얼 스튜디오에 살고 닷넷 개발자입니다

Modernizr.load([ 
    { 
     load: [ 
     'path/to/something.js',, // <--removing this extra comma resolved the issue 
     'path/to/something-else.js' 
     ] 
    } 
]); 
0

을 나는 일반 'Modernizr' NuGet package을 사용하고이 같은 문제에 발견 : 그것은 Modernizr.load()을 포함하지 않습니다 (일명 YepNope).

load() 함수이 포함 된 alternative NuGet package 'Modernizr full'을 사용하기 위해 .NETters에 팁을 보내고 싶습니다.

게다가 전체 버전에는 축소 된 .js 버전이 포함되어 있지만 일반적인 버전은 포함되어 있지 않습니다 (VS의 Web Essentials extension으로 직접 버전을 생성하는 것이 더 좋음).

'Modernizr full'이 현재 2.6.2 인 반면 주 NuGet 패키지는 최신 버전 (현재 Modernizr v 2.8.3, 최신 버전)으로 보입니다. 그러나 나를 위해 충분합니다. 물론 신축성이 있고 새로 고침이 필요한 경우 Modernizr download 기능을 수락 된 응답 상태로 사용해야합니다.

관련 문제