=波波日志 > JavaScript/Ajax > 扩展IE下的input selectionStart selectionEnd属性=
扩展IE下的input selectionStart selectionEnd属性
firefox有selectionStart和selectionEnd属性,指示被选择的内容的开始和结束位置,如果没有选择,则selectionStart和selectionEnd一样。IE没有selectionStart selectionEnd属性,可以使用下面的代码扩展。
+展开
-HTML
<input onclick="selStart(this)" value="1,22,333,2,322,6,3321"/>
<script type="text/javascript">
function selStart(o){
if(document.selection){
o.focus();
var r = document.selection.createRange(),tr=o.createTextRange();
tr.setEndPoint('endtoend',r);
o.selectionStart=tr.text.length-r.text.length;
o.selectionEnd=tr.text.length;
}
alert(o.selectionStart+'\n'+o.selectionEnd);
}
</script>
<script type="text/javascript">
function selStart(o){
if(document.selection){
o.focus();
var r = document.selection.createRange(),tr=o.createTextRange();
tr.setEndPoint('endtoend',r);
o.selectionStart=tr.text.length-r.text.length;
o.selectionEnd=tr.text.length;
}
alert(o.selectionStart+'\n'+o.selectionEnd);
}
</script>
类别:JavaScript/Ajax 作者:波波 日期:2011-06-11 【评论:0】
相关文章
- ·IE,Firefox下自定义属性获取的异同
- ·IE下的Node对象
- ·扩展Firefox下table控件的原型方法moveRow
- ·firefox实现ie的方法和属性
- ·Firefox textContent属性等效于IE的innerText
- ·修复ie下anchor无法定位的问题
- ·ie和firefox下操作table对象的异同
- ·label标签在IE,w3c浏览器firefox下的区别
- ·button,input type=button按钮在IE和w3c,firefox浏览器区别
- ·在XP SP3下★桌面项目里没有IE的解决办法
- ·IE下未选择textarea的内容时如何保存Range对象
- ·iframe编辑器designMode在IE下on/off切换时的问题
暂时没有评论!
发表留言
热门博文
- AJAX跨域问题解决办法
- ajax问题总结
- jQuery dataType指定为json的问题
- ajax+asp.net+mssql无刷新聊天室
- ajax无刷新上传文件,使用iframe模仿
- ajax对象abort方法
最新博文
- jquery+flash显示图片实时加载进度插件
- jquery浮动层拖动插件
- firefox NPMethod called on non-NPObject wrapped JSObject!错误
- IE浏览器setCapture和releaseCapture介绍
- 51.la统计出问题了
- 隐藏删除ckeditor状态栏
随机博文
- jQuery jsonp跨域原理
- 在FireFox浏览器中asp.net+AJAX传输的中文字符串到服务器端后乱码的问题!!!!
- Javascript风格要素
- 生成与中文字符串相对映的拼音首字母串的函数
- Window.Open参数详解
- 精简版jquery lazyload实现真正的延时图片加载
广告商赞助

