#matchMedia() polyfill
- Authors: Scott Jehl, Paul Irish, Nicholas Zakas
- Spec: dev.w3.org/csswg/cssom-view/#dom-window-matchmedia
- Native support: Chrome since m10, Firefox since 6, and Safari since 5.1
Paul Hayes made tackled this using CSS transitions and their transitionEnd event
His code: https://github.com/fofr/matchMedia.js -- though currently it doesnt support IE6-9, since they dont have transitions, obviously. :)
if (matchMedia('tv').matches) {
// tv media type supported
}
if (matchMedia('only screen and (max-width: 480px)').matches) {
// smartphone/iphone... maybe run some small-screen related dom scripting?
}
if (matchMedia('all and (orientation:landscape)').matches) {
// probably tablet in widescreen view
}