Change dynamically html body background image with javascript

Let’s see how we can change body background image with javascript:

document.body.style.minWidth = "100%";
document.body.style.minHeight = "100%";
document.body.style.backgroundSize = "100% 100%";
document.body.style.backgroundImage = "url(image_path.jpg)";
document.body.style.backgroundRepeat = "no-repeat";
%d bloggers like this: