TextBox在Client端Onfocus的時候,游標停留在最後一個字後面

TextBox在Client端Onfocus的時候,游標停留在最後一個字後面

相關範例程式如下

 


<html>
<head>
<script language="javascript"> 
function cursor2last() { 
	var r = event.srcElement.createTextRange(); 
	r.collapse(false); 
	r.select(); 
} 
</script>

</head>
<body>
<form action="" type="Post">
<input type=text name=text2 value="123456" onfocus="cursor2last()"> 
</form>
</body>
</html>

參考小舖中Bryan大大提供的程式碼

http://www.blueshop.com.tw/board/show.asp?subcde=BRD20080908184657AI8&fumcde=FUM20041006161839LRJ

 


以下是簽名:


Microsoft MVP
Visual Studio and Development Technologies
(2005~2019/6) 
topcat
Blog:http://www.dotblogs.com.tw/topcat