日期:2014-05-16 浏览次数:20366 次
<textarea rows="6" id="txtBox" cols="60" onclick ="ShowFos()">
AAAAAAAAAAAAAA;BBBBBBBBBBBBBBBBBBBBBBBBBBBB;CCCCCCCCCCCCCCCCCCCCCCCCCCC;DDDDDDDDDDDDDDDDDDDDDDDDDD;
</textarea>
<script type="text/javascript">
function ShowFos() {
var obj = document.getElementById("txtBox");
var val = document.getElementById("txtBox").value;
var t1 = val.substr(0, getCursorPosition(obj).start);
var t2 = val.substr(getCursorPosition(obj).start, val.length);
var start = t1.length - (t1.length - t1.lastIndexOf(";"));
end = t1.length + t2.indexOf(";");
if (end > 0) {
obj.style.cursor = "pointer";
if (obj.setSelectionRange) {
obj.setSelectionRange(start,end);
} else {
var range = obj.createTextRange();