<html>
<head>
<title>Test</title>
<script type="text/javascript">
function getCursorPos(ta){
if(ta.value==""){
alert("0, 0");
}
else{
i=0;
ta.pos.moveStart('character', -1);
while (ta.value.substr(0,i)!=ta.pos.text){
ta.pos.moveStart('character', -1);
i++;
}
alert(i%ta.cols + ", " + (i-i%ta.cols)/30);
}
}
</script>
</head>
<body>
<form>
<div>
<textarea onclick="this.pos = document.selection.createRange().duplicate();" onfocus="this.pos = document.selection.createRange().duplicate();" onkeyup="this.pos = document.selection.createRange().duplicate();" rows="10" cols="30"></textarea>
<input type="button" value="get cursor pos" onclick="getCursorPos(this.parentNode.firstChild)" />
</div>
</form>
</body>
</html>