The example in this article describes how to set the background color and background image of the page using javascript. Share it with everyone for your reference, the details are as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <SCRIPT LANGUAGE=javascript> function update(temp) { if(temp == 'color') { document.body.style.backgroundColor="#FFFFFF";//改变背景色 } if(temp == 'img') { document.body.style.backgroundImage="url(images/bgimg.gif)";//改变背景图片 } } </SCRIPT> </HEAD> <BODY bgcolor="#CCFFFF"> <input type = button value="改变背景色" onclick="update('color')"> <input type = button value="改变背景图片" onclick="update('img')"> </BODY> </HTML>
I hope this article will be helpful to everyone in JavaScript programming.