Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Getting Media Queries working on old IE Re: Getting Media Queries working on old IE

#88788
Mottie
Member

Maybe you could just include all stylesheets on the page and just disable the ones you aren’t using initially (I know it’s not ideal):

add all of the CSS stylesheets into the head of your page (include a title attribute in each one):






Then use this script. You may get a flash of white if you don’t have a base CSS style (one link that isn’t disabled).

$(document).ready(function(){
adjustCSS();
$(window).resize(function(){ adjustCSS() });
})
function adjustCSS(){
var pageWidth = $(window).width();
var sizeSelected = "blue1";
if (pageWidth > 510) { sizeSelected = "blue2"; }
if (pageWidth > 580) { sizeSelected = "blue3"; }
if (pageWidth > 900) { sizeSelected = "blue4"; }
if (pageWidth > 1010) { sizeSelected = "blue5"; }
if (pageWidth > 1420) { sizeSelected = "blue6"; }
var lnk = $('head').find('link[title=' + sizeSelected + ']').removeAttr('disabled');
$('head').find('link[title]').not(lnk).attr('disabled', 'disabled');
}