function createRect(num) { var newMark=document.createElement("<div id='mark"+num+"'></div>"); edit.insertBefore(newMark); var oRcts = oTempRange.getClientRects();//oTempRange是一个 TextRange 对象 for(var i=0;i<oRcts.length;i++) { var t=oRcts[i].top; var l=oRcts[i].left; var r=oRcts[i].right; var b=oRcts[i].bottom; var newRect=document.createElement("<v:roundRect oncontextmenu='popID="+num+";popUp();' id='Rect"+num+"no"+i+"' style='position:absolute;visibility:hidden' filled=f strokeColor=red strokeWeight=1.5pt></v:roundRect>"); newMark.insertBefore(newRect); newRect.style.posTop=t+document.body.scrollTop-3; newRect.style.posLeft=l-2; newRect.style.width=r-l; newRect.style.height=b-t; newRect.style.visibility=""; } }