可视区尺寸 ------document.documentElement.clientWidth ------document.documentElement.clientHeight
滚动距离 ------document.body.scrollTop ------document.documentElement.scrollTop
系统对话框
警告框:alert(“内容”),没有返回值
选择框:confirm(“提问的内容”),返回boolean 点确定,返回true 点取消或关闭,返回false
<script> var res=confirm('你是否要删除'); alert(res); //点确定,返回true //点取消或关闭,返回false </script>window对象常用事件
onload:加载onscroll:滚动onresize:改变大小例子:右下角悬浮框
<style> #div1 {width:200px; height:150px; background:red; position:absolute; right:0; bottom:0;} body {height:2000px;} </style> <script> window.onscroll=window.onresize=function () { var scrollTop=document.documentElement.scrollTop||document.body.scrollTop; var oDiv=document.getElementById('div1'); oDiv.style.top=document.documentElement.clientHeight-oDiv.offsetHeight+scrollTop+'px'; }; </script> </head> <body> <div id="div1"></div> </body>