jQuery Object expected in Internet Explorer (IE8 and -)

瘦欲@ 提交于 2020-01-05 07:47:13

问题


I get the following error message on IE8 and under: Object expected.

It works OK with all other browsers.

The site is http://www.gablabelle.com/

But I can't find what's wrong.

var layoutI = 0;
var $container = $("#stream");
var $window = $(window);
function reLayout(){  
    var mediaQueryId = getComputedStyle( document.body, ':after' ).getPropertyValue('content');
    var mediaQueryId = mediaQueryId.replace( /"/g, '' );
    var windowSize = $window.width();
    var masonryOpts;
    switch ( mediaQueryId ) {
        case 'bigger' :
            masonryOpts = {
                columnWidth: 270,
                gutterWidth: 30
            };
        break;
        case 'big' :
            masonryOpts = {
                columnWidth: 220,
                gutterWidth: 20
            };
        break;
        case 'medium' :
            masonryOpts = {
                columnWidth: 166,
                gutterWidth: 20
            };
        break;
        case 'small' :
            masonryOpts = {
                columnWidth: $container.width() / 2,
                gutterWidth: 0
            };  
        break;
    };
    $container.isotope({
        resizable: false, // disable resizing by default, we'll trigger it manually
        itemSelector : "article.post",
        animationEngine: "best-available",
        masonry: masonryOpts,
        onLayout: function() {
        //  console.log('layout!' + (layoutI++) )
            forceLoad();
            setTimeout(function(){
                html_height = $container.height();
                $("#sidebar").height(html_height - masonryOpts.gutterWidth);
            }, 500);
        }
    });
};
$container.imagesLoaded( function(){
    reLayout();
    $window.smartresize( reLayout );
});

Many thanks for your help.


回答1:


The error is on getComputedStyle(). This is not supported by IE<8

See here for the support chart.

You could use an alternative like this.



来源:https://stackoverflow.com/questions/12850737/jquery-object-expected-in-internet-explorer-ie8-and

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!