Created
August 6, 2010 04:02
-
-
Save fojas/510815 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery extension for checking if css media query is supported | |
(function($){ | |
$.mediaCheck = function (qry){ | |
var ret, | |
style = document.createElement('style'), | |
id = 'mqc_'+Math.floor(Math.random()*100)+new Date().getTime(), | |
rules = document.createTextNode('@media '+qry+' {#'+id+'{visibility:hidden !important}}'), | |
head = $('head')[0]; | |
body = $('body'); | |
style.type = 'text/css'; | |
if(style.styleSheet){style.styleSheet.cssText=rules.nodeValue;} | |
else{style.appendChild(rules);} | |
head.appendChild(style); | |
// div should not be seen | |
body.prepend('<div id="'+id+'" style="display:none" />'); | |
ret = $('#'+id).css('visibility') == 'hidden'; | |
//clean up | |
body.remove('#'+id); | |
return ret; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment