Following to this problem I had. I'm trying to apply the following fix to get getComputedStyle to work with IE8 (and -) in the code I use for jQuery isotope. But I still get an error message. Any help would be greatly appreciated.
I get 'null' is null or not a object error message with IE-Tester. The website is http://www.gablabelle.com/
$(document).ready(function(){
var layoutI = 0;
var $container = $("#stream");
var $window = $(window);
//getComputedStyle fix for IE ?
if (!window.getComputedStyle) {
window.getComputedStyle = function(el, pseudo) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop == 'float') prop = 'styleFloat';
if (re.test(prop)) {
prop = prop.replace(re, function () {
return arguments[2].toUpperCase();
});
}
return el.currentStyle[prop] ? el.currentStyle[prop] : null;
}
return this;
}
};
function reLayout(){
// getComputedStyle is used here
var mediaQueryId = getComputedStyle( document.body, ':after' ).getPropertyValue('content');
// fix for firefox, remove double quotes
var mediaQueryId = mediaQueryId.replace( /"/g, '' );
// console.log( mediaQueryId );
var windowSize = $window.width();
var masonryOpts;
// update sizing options
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);
}
});
};
// start up isotope with default settings
$container.imagesLoaded( function(){
reLayout();
$window.smartresize( reLayout );
});
Following @Nelson 's logic I decided to add the value I wanted to catch using jQuery instead of CSS to make sure it was in the DOM and can be manipulated.
jQuery:
HTML (can be added anywhere):
CSS (I don't think the media queries part is mandatory since we set this up in jquery):