getting the cursor position in the textarea by using java script
//script type="text/javascript"
function s(el){
var sel, rng, r2, i=-1;
if(typeof el.selectionStart=="number") {
i=el.selectionStart;
} else if(document.selection && el.createTextRange) {
sel=document.selection;
if(sel){
r2=sel.createRange();
rng=el.createTextRange();
rng.setEndPoint("EndToStart", r2);
i=rng.text.length;
}
} else {
el.onkeyup=null;
el.onclick=null;
}
el.form.elements["position"].value=i;
}
/script>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment