售前咨询 售后咨询
当前位置: 上海网站设计 > 建站知识 > 网站托管运营

点击按钮改变网页背景图片

网站编辑:小润 | 发表时间:2019-02-03 23:19:02

    我们希望点击一个按钮,改变网页背景图片,这样改怎么做呢?下面润壤网络给出代码,经过测试是可以使用的,不过建议大家的是:代码里面的圆角符号都要换成英文状态下的,使用查找替换可能会更好一点。

<html>
<head>
<title>点击按钮改变网页背景图片怎么做-来自于www.02168.net</title>
<style type="text/css">
<!--
.bgimages {
color: #993333;
font-weight: bold;
width:60ox; height:28px; background:#eaeaea;
}
-->
</style>
</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 class="bgimages" onClick="tile();event.cancelBubble=true"><span class="bgimages" onClick="tile();event.cancelBubble=true"><img src="http://www.02168.net.cn/d/file/products/yure/penyou/2012-12-27/f49a9bae6700322893780ffb6604cb0f.jpg" height=310 width=228 border=2></span><img src="http://www.02168.net.cn/d/file/products/houchuli/guolvqi/2012-12-27/a4563ebb4e6f17df77e71d5d1a68ae50.jpg" height=310 width=228 border=2>
<img src="http://www.02168.net.cn/d/file/products/houchuli/xifu/2012-12-27/70d6040847d6c98377412667f99f1c47.jpg" height=310 width=228 border=2>
<img src="http://www.02168.net.cn/d/file/products/houchuli/lengdong/2012-12-27/3864ddf6fec906b5d5d4e53445442499.jpg" height=310 width=228 border=2></span></p>
</td>
</tr>
</table>
</center>
</body>
</html>

关键字:
官方微信
上海市长宁区宣化路300号华宁国际广场中区7层
+021-8031 0607
+135 8590 1130