写的比较乱,各位看官就将就吧
<script>
function tellPoint() {
var rng = event.srcElement.createTextRange();
rng.moveToPoint(event.x, event.y);
rng.moveStart("character", -event.srcElement.value.length)
pnum.value = rng.text.length
t.innerText = rng.text;
var str=rng.text;
var insertStr="!!!!!!!!这是插入的字符!!!!!!!!!"
var str1=box.value.substr(rng.text.length,(box.value.length-rng.text.length))
box2.value=str+insertStr+str1;
}
</script>
<textarea rows = "7" cols = "49" id = "box" onclick = tellPoint()>我怕来不及我要抱着你,直到感觉你的绉纹有了岁月的痕迹,直到视线变得模糊直到不能呼吸
</textarea><br>
光标位置:<input type = "text" value = "0" id = "pnum" size = "8"><br>
text:<span style = "position: absolute; z-index: 10" id = "t"></span>
<br>
<br>
<br>
<textarea id="box2" rows = "7" cols = "49">
</textarea>