First code is working on Firefox, Opera and Internet Explorer.
Code:
<html>
<head>
</head>
<body>
<div>
<input id="myDeger" type="text" value="5" size="20"><input type="button" value="sıradaki karaktere git" onclick="konumlandir(myKutu,myDeger.value);">
</div>
<textarea id="myKutu" name="myKutu" rows="3" cols="30" style="height: 300px; width: 300px">abcdefg</textarea>
<script>
function konumlandir(kutu,posizyon) {
myKutu.focus();
if( kutu.setSelectionRange ) {
kutu.setSelectionRange(posizyon,posizyon);
}
else if( kutu.createTextRange ) {
var aralik = kutu.createTextRange();
aralik.collapse(true);
aralik.moveEnd('character',posizyon);
aralik.moveStart('character',posizyon);
aralik.select();
}
}
</script>
</body>
</html>
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function kursor () {
var el = document.getElementById('textareaid');
el.focus();
el.setSelectionRange(el.value.length,el.value.length);
alert(el.selectionStart+"\n"+el.selectionEnd)
return false;
}
</script>
</head>
<body>
<textarea id="textareaid">now is the time</textarea>
<br />
<a href="#"
onclick="kursor ()">
position cursor w/setSelectionRange
</a>
<br /><br />
</body>
</html>
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function kursor () {
var el = document.getElementById('textareaid');
el.focus();
el.setSelectionRange(3,3);
alert(el.selectionStart+"\n"+el.selectionEnd)
return false;
}
</script>
</head>
<body>
<textarea id="textareaid">now is the time</textarea>
<br />
<a href="#"
onclick="kursor ()">
position cursor w/setSelectionRange
</a>
<br /><br />
</body>
</html>
http://vebgelistirme.googlepages.com/jseditor.htm
Bookmarks