<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<style type= "Text/css" >
#rectBox
{
Background: #CCFFFF;
border:2px solid #0099FF;
Filter:alpha (opacity=30);
opacity:0.3;
Position:absolute;
}
</style>
<title> a mouse selection box </title>
<script type= "Text/javascript" >
function Rect ()
{
This.doc = document.documentelement;
if (!this.doc) return;
This.startx = ";
This.starty = ";
This.rect = null;
Rectself = this;
}
Rect.prototype.down = function (e)
{
var e = e?e:window.event;
Rectself.startx = E.clientx?e.clientx + Document.body.scrollleft:e.pagex;
Rectself.starty = E.clienty?e.clienty + document.body.scrolltop:e.pagey;
Rectself.showrect (TRUE);
}
Rect.prototype.up = function (e)
{
RectSelf.rectBox.style.width = ' 0px ';
RectSelf.rectBox.style.height = ' 0px ';
Rectself.showrect (FALSE);
}
Rect.prototype.move = function (e)
{
if (Rectself.rectbox)
{
var CurrentX = E.clientx?e.clientx + Rectself.doc.scrollleft:e.pagex;
var currenty = E.clienty?e.clienty + rectself.doc.scrolltop:e.pagey;
RectSelf.rectBox.style.width = Math.Abs (currentx-rectself.startx) + ' px ';
RectSelf.rectBox.style.height = Math.Abs (currenty-rectself.starty) + ' px ';
if (Currentx-rectself.startx < 0)
{
RectSelf.rectBox.style.left = CurrentX + ' px ';
}
if (Currenty-rectself.starty < 0)
{
RectSelf.rectBox.style.top = currenty + ' px ';
}
Document.title = "Left:" +currentx + ' px ' + "top:" +currenty + ' px ';
}
}
Rect.prototype.showRect = function (bool)
{
if (BOOL)
{
if (!this.rectbox)
{
This.rectbox = document.createelement ("div");
This.rectBox.id = "Rectbox";
Document.body.appendChild (This.rectbox);
}
This.rectBox.style.display = "block";
This.rectBox.style.left = this.startx + ' px ';
This.rectBox.style.top = this.starty + ' px ';
This.addeventlistener (This.doc, ' MouseMove ', this.move);
}
Else
{
if (This.rectbox)
{
This.rectBox.style.display = "None";
}
This.removeeventlistener (This.doc, ' MouseMove ', this.move);
}
}
Rect.prototype.addEventListener = function (o,e,l)
{
if (O.addeventlistener) {
O.addeventlistener (E,l,false);
} else if (o.attachevent) {
O.attachevent (' on ' +e,function () {
L (window.event);
});
}
}
Rect.prototype.removeEventListener = function (o,e,l)
{
if (O.removeeventlistener) {
O.removeeventlistener (E,l,false);
} else if (o.detachevent) {
O.detachevent (' on ' +e,function () {
L (window.event);
});
}
}
Window.onload = function ()
{
var orect = new Rect ();
Orect.addeventlistener (Orect.doc, ' MouseDown ', orect.down);
Orect.addeventlistener (Orect.doc, ' MouseUp ', orect.up);
}
</script>
<body>
<div>http://www.999jiujiu.com/</div>
</body>
Light blue mouse Drag selection box