请问如何得到文本框的光标位置? 我是说<input type="text" name=".... >的文本框. 神啊,救救我吧! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我可以给你一个比较曲折的方法(如下)。也许还有其他方法,<input type=text id=edit1 value="hello,world"><button onclick=alert(GetCurPos())>看光标位置</button><script>function GetCurPos(){ edit1.focus(); var SaveStr=edit1.value; document.execCommand('paste','','pos'+SaveStr); var pos=edit1.value.indexOf('pos'+SaveStr); edit1.value=SaveStr; return pos}</script> 看看http://www.csdn.net/develop/add_article.asp也许会对你有帮助!! 这个比较简单。。给你个好玩的东西看看,是我自己编写的:<html><head><style type=css/text> #aa{ margin-left: 400; margin-top: 200; background-color: #ffffff; }</style></head><body><form name=f><input type=button name=a id=aa><input type=button name=b></form><script language=JavaScript> function click() { document.f.a.value=event.clientX+","+event.clientY document.f.b.value=' '; while(document.f.b.value.charAt(event.clientX%80,event.clientX%80+1)!=' ') document.f.b.value+=' ';} document.onmousemove=click</script></body> 别忘了,给我分数呀! 其实,就是一个event.clientX 和 event.clientY,就可以取得鼠标的位置了。。当然,你也就知道,怎么取得文本矿的位置了 正则表达匹配 关于GOOGLE地图if (GBrowserIsCompatible()) 不兼容IE的问题 JS数组的几个问题 js 动态添加、删除行 Ajax发送请求的问题 关于IE和FF中"cursor:url"样式不兼容的问题... javascript验证简单的数学公式该如何写?谢谢! web打印功能 请大家帮帮忙! 关于excel的复制和样式问题 可以实现仅使用JavaScript做一个获取汉字拼音首字母的函数吗? java script 事件问题(急急急急急....要命) help :谁能看出网络名片网上www.gonamecard.com的名片选择是如何做的?我也想做这样的
也许还有其他方法,
<input type=text id=edit1 value="hello,world">
<button onclick=alert(GetCurPos())>看光标位置</button>
<script>
function GetCurPos()
{
edit1.focus();
var SaveStr=edit1.value;
document.execCommand('paste','','pos'+SaveStr);
var pos=edit1.value.indexOf('pos'+SaveStr);
edit1.value=SaveStr;
return pos
}
</script>
http://www.csdn.net/develop/add_article.asp
也许会对你有帮助!!
<html>
<head>
<style type=css/text>
#aa{
margin-left: 400;
margin-top: 200;
background-color: #ffffff;
}
</style>
</head>
<body>
<form name=f>
<input type=button name=a id=aa>
<input type=button name=b>
</form>
<script language=JavaScript>
function click()
{
document.f.a.value=event.clientX+","+event.clientY
document.f.b.value=' ';
while(document.f.b.value.charAt(event.clientX%80,event.clientX%80+1)!=' ')
document.f.b.value+=' ';
}
document.onmousemove=click
</script>
</body>
其实,就是一个event.clientX 和 event.clientY,就可以取得鼠标的位置了。。
当然,你也就知道,怎么取得文本矿的位置了