当前位置: 主页 > 建站知识 > 网站设计知识 >

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

来源:  作者:   日期:2014-09-27 11:33

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

<html>
<head>
<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.ymars.com.cn/d/file/products/yure/penyou/2012-12-27/f49a9bae6700322893780ffb6604cb0f.jpg" height=310 width=228 border=2></span><img src="http://www.ymars.com.cn/d/file/products/houchuli/guolvqi/2012-12-27/a4563ebb4e6f17df77e71d5d1a68ae50.jpg" height=310 width=228 border=2>
<img src="http://www.ymars.com.cn/d/file/products/houchuli/xifu/2012-12-27/70d6040847d6c98377412667f99f1c47.jpg" height=310 width=228 border=2>
<img src="http://www.ymars.com.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>


上一篇:上一篇:网站设计必须具备的几大标准
下一篇:下一篇:网站内页怎么保持风格一致

政府网站、电商网站、企业网站、淘宝装修就选创意网络     24小时热线:15195232629