关于层在窗体中的移动
<!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>
<script language= "javascript ">
function move(){
var now_left = document.getElementById( "movelayer ").style.left;
var window_width = document.body.offsetWidth;
var now_top = document.getElementById( "movelayer ").style.top;
var window_height = window.screen.height;
if ((parseInt(now_left) + 80) < window_width){
top_left_move();
setTimeout ( "move() " ,1);
}
else if ((parseInt(now_top) + 80) < window_height){
right_down_move();
setTimeout ( "move() " ,1);
}
else {
var stop = setTimeout ( "move() " ,1);
clearTimeout (stop);
move_down_up();
}
}
function top_left_move(){
var now_left = document.getElementById( "movelayer ").style.left;
var window_width = document.body.offsetWidth;
if ((parseInt(now_left) + 80) < window_width){
document.getElementById( "movelayer ").style.left = parseInt(now_left) + 1;
var stop = setTimeout( "top_left_move() ", 100);
}
else {
clearTimeout (stop);
return ;
}
}
function right_down_move(){
var now_top = document.getElementById( "movelayer ").style.top;
var window_height = window.screen.height;
if ((parseInt(now_top) + 80) < window_height){
document.getElementById( "movelayer ").style.top = parseInt(now_top) + 1 ;
var stop = setTimeout( "right_down_move() ", 100);
}
else {
clearTimeout (stop);
return ;
}
}
function move_down_up(){
var now_left = document.getElementById( "movelayer ").style.left;
var now_top = document.getElementById( "movelayer ").style.top;
if (parseInt(now_left) > 0 ){
down_left_move();
setTimeout ( "move_down_up() " ,1);
}
else if (parseInt(now_top) > 0 ){
left_up_move();
setTimeout ( "move_down_up() " ,1);
}
else {
var stop = setTimeout ( "move_down_up() " ,1);
clearTimeout (stop);
move();
}
}
function down_left_move(){
var now_left = document.getElementById( "movelayer ").style.left;
if (parseInt(now_left) > 0 ){
document.getElementById( "movelayer ").style.left = parseInt(now_left) - 1;
var stop = setTimeout( "down_left_move() ",