This article describes the method of clicking on images to change the background image of the page in js. Share it for your reference. The specific implementation method is as follows:
Copy the code as follows: <html>
<head>
<title>Click on the picture to change the background image of the page</title>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" marginwidth="0">
<script language="JavaScript1.2">
<!--
function tile(){
if (!document.all)
Return
var source=event.srcElement
if (source.tagName=="IMG")
document.body.style.backgroundImage="url("+source.src+")"
}
function restore(){
document.body.style.backgroundImage=''
}
document.body.ondblclick=restore
-->
</script>
</p>
<p align="center"><span onClick="tile();event.cancelBubble=true">
<img src="/images/m01.jpg" height=65 width=96 border=2>
<img src="/images/m02.jpg" height=65 width=96 border=2>
<br>
<img src="/images/m03.jpg" height=65 width=96 border=2>
<img src="/images/m04.jpg" height=65 width=96 border=2></span></p>
</td>
</tr>
</table>
</center>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.