87,904
社区成员
发帖
与我相关
我的任务
分享
<div id='container'>
<div id='header'>
</div>
<div id='content'>
</div>
</div>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<style type="text/css">
A {
text-decoration:none;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
//当前的宽度
var curLeft = 0;
//当前的高度
var curTop = 0;
//鼠标移动的X坐标
var curClientX = 0;
//鼠标移动的Y坐标
var curClientY = 0;
var curBool = false;
//鼠标点击事件
function show() {
curLeft = document.getElementById("container").style.pixelLeft;
curTop = document.getElementById("container").style.pixelTop;
curClientX = event.clientX;
curClientY = event.clientY;
document.onmousemove = showDown;
curBool = true;
}
//鼠标划过事件
function showDown() {
if (curBool) {
var curX = event.clientX; //鼠标划过的X轴坐标
var curY = event.clientY;//鼠标划过的Y轴坐标
document.getElementById("container").style.pixelLeft = curLeft + (curX - curClientX);
document.getElementById("container").style.pixelTop = curTop + (curY - curClientY);
}
}
//当前div的高度
var curHeight = 0;
//当前div位置的高度
var highttTop = 0;
//当前的高度
var curHeightTop = 0;
//移动的步数
var start = 20;
//窗体加载是初始化
function showHeight() {
curHeight = document.getElementById("container").offsetHeight;
highttTop = document.getElementById("container").style.pixelTop;
}
//小化事件
function showMin() {
curHeightTop = document.getElementById("container").offsetHeight;
if (curHeightTop <= start) {
curHeightTop = start;
return;
} else {
curHeightTop = curHeightTop - start;
document.getElementById("container").style.height = curHeightTop + "px";
}
setTimeout("showMin()",100);
}
//大化事件
function showMax() {
if (curHeightTop >= curHeight) {
curHeightTop = curHeight;
return;
} else {
curHeightTop = curHeightTop + start;
document.getElementById("container").style.height = curHeightTop + "px";
}
setTimeout("showMax()",100);
}
//当前top位置
var topHeigth = 0;
//下框的top位置
var topId = 0;
//最大宽度
var curWidth = 0
//当前left位置
var curLeftWidth = 0;
//最小化事件
function showHeightMin() {
showMin();
topHeigth = document.getElementById("container").style.pixelTop;
curLeftWidth = document.getElementById("container").style.pixelLeft;
topId = document.getElementById("content").style.pixelTop;
curWidth = document.body.offsetWidth - document.getElementById("container").offsetWidth;
if (curLeftWidth <= 0) {
curLeftWidth = 0;
}
if (topHeigth >= topId) {
topHeigth = topId;
return;
} else {
topHeigth = topHeigth + start;
document.getElementById("container").style.pixelTop = topHeigth;
}
setTimeout("showHeightMin()",100);
}
//最大化事件
function showHeightMax() {
if (curLeftWidth >= curWidth) {
curLeftWidth = curWidth;
}
if (topHeigth <= highttTop) {
topHeigth = highttTop;
return;
} else {
topHeigth = topHeigth - start;
document.getElementById("container").style.pixelTop = topHeigth;
}
showMax();
setTimeout("showHeightMax()",100);
}
//关闭事件
function showClose() {
document.getElementById("container").style.display = "none";
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<div id="container" style="position:absolute;height:200px;width:200px;z-index:1;background-color:#0080FF;" onmouseup="curBool = false">
<div style="height:20px;width:200px;text-align:right;background-color:#FF80FF;cursor:hand;" onmousedown="show()">
<A href="javascript:showMin(),showHeight()">-</A>
<A href="javascript:showMax()">+</A>
<A href="javascript:showHeightMin(),showHeight()">最小化</A>
<A href="javascript:showHeightMax()">最大化</A>
<A href="javascript:showClose()">关闭</A>
</div>
</div>
<div id="content" style="position:absolute;width:1190px;height:20px;top:580px;;background-color:#80FF80;">
</div>
</BODY>
</HTML>
var $ = function(o){return document.getElementById(o) || o}
$.Draging = function (drager, container, methods, Initialize) {
var x = y = 0, d = c = null;
if (drager=='undefined'||container=='undefined') return;
d = $(drager), c = $(container);
x = c.offsetWidth - d.offsetWidth;
y = c.offsetHeight - d.offsetHeight;
d.style.position = 'absolute';
typeof Initialize=='function' && Initialize(d, c, x, y);
d.onmousedown = function (e) {
var o = null, m = n = 0, e = e || window.event;
e.preventDefault ? e.preventDefault() : (e.returnValue=!!0);
o = e.srcElement || e.target;
m = e.clientX - parseInt(o.style.left);
n = e.clientY - parseInt(o.style.top );
! +'\v1' && o.setCapture();
document.onmousemove = function (e) {
var _x = _y = 0, e = e || window.event;
_x = e.clientX - m, _y = e.clientY - n;
x > 0 && _x <= x && _x >= 0 && (o.style.left = _x + 'px');
y > 0 && _y <= y && _y >= 0 && (o.style.top = _y + 'px');
typeof methods=='function' && methods(100*_x/x>>0, 100*_y/y>>0);
return false
}
document.onmouseup = function () {
! +'\v1' && o.releaseCapture();
document.onmouseup = document.onmousemove = o = null;
}
}
}