窗口移动,碰到屏幕四周是,窗口进行反弹

<script language="JavaScript">
// window.resizeTo(300, 300)
window.moveTo(0, 0)
inter = setInterval("go()", 10);
var aa = 0
var bb = 0
var a = 0
var b = 0
function go() {
try {
if (aa == 0)
a = a + 2;
if (a > screen.availWidth - 300)
aa = 1;
if (aa == 1)
a = a - 2;
if (a == 0)
aa = 0;
if (bb == 0)
b = b + 2;
if (b > screen.availHeight - 300)
bb = 1;
if (bb == 1)
b = b - 2;
if (b == 0)
bb = 0;
window.moveTo(a, b);
}
catch (e) { }
}
</script>

 


</head>
<body onresize="resizeTo(300,300)">

会自动移动的窗口

</body>

在IE中有效,用到window.Screen对象 

availHeight  返回窗口内容区域的垂直尺寸,以像素为单位

availWidth   返回窗口内容区域的水平尺寸,以像素为单位

 

posted @ 2014-09-13 23:58  冰融心  阅读(210)  评论(0编辑  收藏  举报