function DelLine(obj){
obj.focus();
var r1 = document.body.createTextRange();
var r2 = document.body.createTextRange();
var s = document.selection.createRange();
var re = obj.createTextRange().getClientRects();
var t = s.getBoundingClientRect().top;
for(i=0;i<re.length;i++)if(re[i].top>=t)break;
r2.moveToPoint(re[i].left,re[i].top);
r1.setEndPoint("StartToStart", r2);
r2.moveToPoint(re[i].left,re[i].bottom);
r1.setEndPoint("EndToEnd", r2);
r1.text = "";
}
<textarea name="userlist" id="userlist" ondblclick="DelLine(this)">
0000
aaaa
bbbb
cccc
</textarea>
此函数是用来删除TextArea中某一行的js脚本。在没有frame的页面中测试完全没有问题,但用于frame中的页面就有问题。。怎么回事呢?有人知道吗?谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货