JS多个矩形块选择效果代码(模拟CS结构)
">
大屏屏幕
/css/font.css" rel="stylesheet" type="text/css" />
var canChange = 1;
var candraw = 1;
function main_mouseup()
{
candraw = 0;
}
function init()
{
var aDivs = document.getElementsByTagName("div");
for (var i=0; iid2)&&(id1%list>id2%list)) {startP = id2;endP = id1;}
else{
//alert(DisY);
startP = (id1');
}else{
candraw = 0;
document.getElementById("startid").value = startId;
document.getElementById("endid").value = endId;
window.parent.screenEvent(startId,endId,'');
}
}
function changeEnd(id)
{
//获得了最后的一个格子。
if(candraw == 1){
endId = id;
//alert(endId);
//算法
/*
*根据起始ID 和 最后ID来确定是哪些格子变
* 计算start和end的行,列数
*/
changeColorBySE(startId,endId);
}
}
function neverDragDivision(fObj) { with (this)
{
if (!fObj) return;
this.bDraged = false;
this.oDragOrig = fObj;
oDragOrig.onmousedown = function()
{
oDragOrig.style.backgroundColor="#FFFFFF";
//alert(event.clientY);
//alert(oDragOrig.offsetTop);
//var ofs = Offset(oDragOrig);
// oDragOrig.style.position = "absolute";
//oDragOrig.style.left = ofs.l;
//oDragOrig.style.top = ofs.t;
//alert(oDragOrig.style.top);
//oDragOrig.X = event.clientX - ofs.l;
//oDragOrig.Y = event.clientY - ofs.t;
bDraged = true;
};
/*
oDragOrig.onmousemove = function()
{
if (!bDraged) return;
oDragOrig.setCapture();
oDragOrig.style.left = event.clientX - oDragOrig.X;
oDragOrig.style.top = event.clientY - oDragOrig.Y;
};*/
/*
oDragOrig.onmouseup = function()
{
bDraged = false;
oDragOrig.releaseCapture();
};*/
function Offset(e) {
var t = e.offsetTop;
var l = e.offsetLeft;
var w = e.offsetWidth;
var h = e.offsetHeight;
while(ee=e.offsetParent) {
t+=e.offsetTop;
l+=e.offsetLeft;
}
return { t:t, l:l, w:w, h:h }
};
}};
document.write('
'); document.write(' |
');
function resetcheck(){
for(i=0;i
end id -->
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]