比如说,我想把光标定在可编辑层的第十个字符位置,应该怎么做呢?谢谢
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
dfsifdogihsdfoi
<div style="border:1px solid red;" contentEditable=true>fsfghsofdugosfydgsdfghosdfuyg dfuosifudso sfdyosudf</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
dfsifdogihsdfoi
<div style="border:1px solid red;" contentEditable=true>fsfghsofdugosfydgsdfghosdfuyg dfuosifudso sfdyosudf</div>
</body>
</html>
解决方案 »
- 如何使用表单结合javascript改变网页图片的大小?
- 求一个简单代码的解释~~!
- 用JSP做的网站,如何发布到局域网中?具体步骤
- 客户端IE禁止弹出窗口 如何写代码 仍能强制弹出窗口?
- 急!ASP页面有多个分页时,如何实现多个页面自动翻页?setinterval可以实现吗?如何实现?
- js读取excel有部分内容显示不出来
- 问个js问题,有点急。。。
- 这样写为什么出错了?
- 我的服务器安装了2000server,我要做到每天下班自动定时关闭服务器,请问如何做到,需要下载什么软件?
- 打开新窗口后,gif图不动了?
- 如何捕获鼠标点击的控件?
- 求助大侠,关于IE7不能浏览部分javascript网页特效的问题
<html xmlns="http://www.w3.org/1999/xhtml" >
<head >
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" / >
<title >无标题文档 </title >
</head > <body >
dfsifdogihsdfoi
<div style="border:1px solid red;" contentEditable="true" id="jia">fsfghsofdugosfydgsdfghosdfuyg dfuosifudso sfdyosudf </div>
<script language="javascript">
function f(){
var rng = document.selection.createRange();
rng.moveStart("character",10);
rng.select();
}
window.onload = function(){
document.getElementById("jia").focus();
f();
}
</script>
</body >
</html >