function drawRect(x1,y1,w,h){
var newRect=document.createElement('<v:rect filled="false" style="position:absolute;top:'+(y-h/2)+';left:'+(x-w/2+';width:"+w+";height:"+h></v:rect>');
document.body.insertBefore(newRect);
}
自己调试一下看看行不行
我没有判断边界问题,需要的话自己判断一下
var newRect=document.createElement('<v:rect filled="false" style="position:absolute;top:'+(y-h/2)+';left:'+(x-w/2+';width:"+w+";height:"+h></v:rect>');
document.body.insertBefore(newRect);
}
自己调试一下看看行不行
我没有判断边界问题,需要的话自己判断一下
document.getElementsByTagName("BODY")[0].innerHTML += '<div style="border:solid 1px #0099cc;position:absolute;top:'
+ (y1-h/2) + 'px;left:' + (x1-w/2) + 'px;width:' + w + 'px;height:' + h + 'px;"> </div>';
}
drawRect(400,220,400,300);
drawRect(300,220,400,300);我想我没有算错...楼上的少了个括号..:(