1:做网页上浮动广告
<html>
<head>
<title>制作浮动的广告图片</title>
<script language="javascript" type="text/javascript">
<!--
var advInitTop=100;//层距离顶端的初始值
function move()
{
window.document.getElementById("advLayer").style.top=advInitTop+window.document.body.scrollTop;
}
window.onscroll=move;//窗口的滚动事件,当页面滚动时调用move()函数
//-->
</script>
</head>
<body >
<div id="advLayer" style="position:absolute;left:16px;top:129px;width:180px;height:230px; z-index:1;">
<img src="cat.jpg" />
</div>
在这里加文字用来产生滚动条 img src="cat.jpg" 根据实际情况更改
window.onscroll=move;可去掉 然后 把<body >换成<body onscroll="move()">
注意window.onscroll=move;不能写为window.onscroll=move();
</body>
</html>
2.改变指定元素的值
<html>
<head>
<title>
wangye</title>
<script type="text/javascript">
function changelink(){
document.getElementById('myanchor').innerHtml="搜狐";
document.getElementById('myanchor').href="#";
}
</script>
</head>
<body>
<a id="myanchor" href="#" >百度</a>
<form name="myform">
<input type="button" value="更换连接" onClick="changelink()" />
</form>
</body>
</html>