<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>测试层滚动</title> </head> <body onload = "openwindow()"> <div id = "play" style = "position:absolute;height:2000px;width:990px;background-color:orange;z-index:1"></div> <div id = "player" style = "position:absolute;height:100px;width:100px;left:900px;top:100px;background-color:blue;z-index:2"></div> <div id = "myplay" style = "position:absolute;heigth:20px;width:40px;left:970px;top:80px;z-index:3" onclick = "guna()"><font size = 3 color = red><a href = "#">关闭</a></font></div> </body> </html> <mce:script language = "javascript"><!-- var checks = 0; var GB =0; function openwindow() { checks = document.getElementById("player").style.pixelTop; GB = document.getElementById("myplay").style.pixelTop; } function move() { //alert("s") document.getElementById("player").style.pixelTop = checks + document.documentElement.scrollTop; document.getElementById("myplay").style.pixelTop = GB + document.documentElement.scrollTop; } function guna() { document.getElementById("myplay").style.display = "none"; document.getElementById("player").style.display = "none"; } window.onscroll = move; // --></mce:script>