环境: IE7 .NET1.1 WIN2003 IIS6
代码:
<div id= "divMap " runat= "server " style= "CURSOR:crosshair; " onmousedown= 'down(window.event); '
onmouseup= 'up(window.event); ' onmousemove= 'move(window.event); '>
<img id= "imgMineMap " runat=server width= "750 " height=680 style= "BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid ">
<div id= 'rect ' style= 'BORDER-RIGHT:#ff0000 1px solid; BORDER-TOP:#ff0000 1px solid; BORDER-LEFT:#ff0000 1px solid; BORDER-BOTTOM:#ff0000 1px solid; POSITION:absolute '> </div>
</div>
<script language= "javascript ">
// 是否需要(允许)处理鼠标的移动事件,默认识不处理
var select = false;
var rect = document.getElementById( "rect ");
// 设置默认值,目的是隐藏图层
rect.style.width = 0;
rect.style.height = 0;
rect.style.visibility = 'hidden ';
//让你要画的图层位于最上层
rect.style.zIndex = 1000;
// 记录鼠标按下时的坐标
var downX = 0;
var downY = 0;
// 记录鼠标抬起时候的坐标
var mouseX2=downX;
var mouseY2=downY;
//处理鼠标按下事件
function down(event){
// 鼠标按下时才允许处理鼠标的移动事件
select = true;
//让你要画框的那个图层显示出来