You may check the window width and change the background depending on the results.
var width = window.innerWidth;
var height = window.innerHeight;
var body = document.body;
if (width <= 1600 && height <= 1000) {
body.style.background = "url(path/to/1600x1000.jpg)";
}
if (width <= 1400 && height <= 900) {
body.style.background = "url(path/to/1400x900.jpg)";
}
// continue as desired
Even better, use some media queries to reduce javascript required.
@media screen and (max-width: 1600px) {
.element {
background: url(path/to/1600x1000.jpg);
}
}
@media screen and (max-width: 1400px) {
.element {
background: url(path/to/1400x900.jpg);
}
}