一、bgColor属性
......
function change(color)
{
document.bgColor=color ;
}
......
<SPAN onMouseOver="change('red')">变红色</SPAN>
<SPAN onMouseOver="change('blue')">变蓝色</SPAN>
<SPAN onMouseOver="change('yellow')">变黄色</SPAN>
......
//onMouseOver鼠标悬停事件
//容器标签<SPAN>
二、如何制作带关闭按钮的浮动广告,并随滚动条移动?
思路:1、在页面中插入两层,分别是广告层和关闭层
2、编写脚本:a、使用getElementById( )方法获得层对象
......
var advInitTop=0;
var closeInitTop=0;
function inix( )
{
advInitTop=document.getElementById("advLayer").style.pixelTop;
closeInitTop=document.getElementById("closeLayer").style.pixelTop; //pixelTop返回“129”;注意与Top的区别
}
function move( )
{
document.getElementById("advLayer").style.pixelTop=advInitTop+document.body.scrollTop;
//注意与document.getElement.scrollTop的区别:关键看浏览器能够识别不
document.getElementById("closeLayer").style.pixelTop=closeInitTop+document.body.scrollTop;
}
function closeMe( )
{
document.getElementById("closeLayer").style.display="none";
//display="block"则为显示
document.getElementById("advLayer").style.display="none";
}
window.onscroll=move ; //窗口的滚动事件,当页面滚动时调用move( )函数
......
<BODY onload="inix( )" >
<DIV id="closeLayer" onclick="closeMe( )" style="position:absolute; left:166px; top:132px; width:27px; height:19px;z-index:2;">
<IMG src="images/close.jpg" width="26" height="18"></DIV>
<P> </P>
<P><IMG src="images/contentpic.jpg" width="993" height="1799"></P>
<P> </P>
<DIV id="advLayer" style="position:absolute; left:16px; top:129px; width:144px; height:95px; z-index:1;"><A href="http://www.taobao.com"><IMG src="images/advpic.gif" width="180" height="230" border="0"></A></DIV>
......
//getElementsByName( ):
......
<a href="javascript:checkAll(true)">全选</a>
<a href="javascript:checkAll(false)">不全选</a>
......
<input type="checkbox" id="isBuy" name="isBuy" value="sanguo">
......
<input type="checkbox" id="isBuy" name="isBuy" value="jingwu">
03:26:43 PM
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛