This example describes how JavaScript sets the background color and background image of a page. Share to everyone for your reference, specific 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";//change background color
}
if (temp = ' img ')
{
Document.body.style.backgroundimage= "url (images/bgimg.gif)";//change background picture
}
}
</SCRIPT>
</HEAD>
<body bgcolor= "#CCFFFF" >
<input type = button value= "Change background color" onclick= "Update (' Color ' ">
<input type = button value=" Change background picture "onclick=" Update (' img ') ">
</BODY>
I hope this article will help you with JavaScript programming.