Of course. This is simple implementation in HTML
<html><head><title> Test indexOf currsor </title><script type="text/javascript" language="javascript">function caret(node) { //node.focus(); /* without node.focus() IE will returns -1 when focus is not on node */ if(node.selectionStart) return node.selectionStart; else if(!document.selection) return 0; var c = "\001"; var sel = document.selection.createRange(); var dul = sel.duplicate(); var len = 0; dul.moveToElementText(node); sel.text = c; len = (dul.text.indexOf(c)); sel.moveStart('character',-1); sel.text = ""; return len;}</script></head><body> <div id="testContent"> <textarea id="textarea" style="width: 80%; height: 100px;"> Some example text ... </textarea> <br/> <p>Postion cursor: </p><input type="text" id="pz" /> <script type="text/javascript"> var indicator = document.getElementById("pz"); var textarea = document.getElementById("textarea"); setInterval(function() { indicator.value = caret(textarea);}, 100); </script> <div></body></html>
Regards Pawel
To use the full functionality of this web site, JavaScript needs to be turned on.
For best results, use the Firefox browser..
Copyright © 2003-2017 - Tersus Software Ltd., All rights reserved. Terms of Use License Graphic design by EmaraDesign