I want to select a CSS file using a variable from a piece of JS. I'm working on feature detecting to select a specific CSS. Here is the code I'm using to determine the resolution of a screen. I would like to use either "RES" or "device" to select an external CSS. Thanks.
function hasTouch() {
return Modernizr.touch;
}
var RES = window.screen.availWidth
function detectDevice() {
if (hasTouch()) {
if (RES < 600) {
device = 'phone';
} else {
device = 'tablet';
}
}
if (RES > 600 && RES < 1025) {
device = 'Medium';
}
if (RES > 1025 && RES < 1367) {
device = 'Large';
}
if (RES > 1367) {
device = 'XL';
}
return device;
}
document.querySelector('#device').innerHTML = detectDevice();