问题
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