用javascript获取选中的文字
2012-01-04 20:44
405 查看
function getSelectText() {
return document.selection && document.selection.createRange().text || window.getSelection && window.getSelection() || document.getSelection && document.getSelection() || '';
}
function getSelectText()
{
var txt = null;
if (window.getSelection){ // mozilla FF
txt = window.getSelection();
}else if (document.getSelection){
txt = document.getSelection();
}else if (document.selection){ //IE
txt = document.selection.createRange().text;
}
return txt;
}
return document.selection && document.selection.createRange().text || window.getSelection && window.getSelection() || document.getSelection && document.getSelection() || '';
}
function getSelectText()
{
var txt = null;
if (window.getSelection){ // mozilla FF
txt = window.getSelection();
}else if (document.getSelection){
txt = document.getSelection();
}else if (document.selection){ //IE
txt = document.selection.createRange().text;
}
return txt;
}
相关文章推荐
- javascript获取选中文字-兼容各浏览器
- javascript如何获取文本控件中选中的文字?
- 用JavaScript获取选中的文字
- Javascript 获取页面上选中的文字
- JavaScript 选中文字并响应获取的实现代码
- JavaScript 响应选中文字并获取
- Javascript 获取页面上选中的文字
- javascript 获取选中的文字
- Html网页中禁止文字选中(css/javascript)
- 【代码片段】javascript下新增、删除一行/选中文字变颜色
- Javascript获取select下拉框选中的的值
- Javascript获取select下拉框选中的的值
- javascript中获取选中对象的类型
- 用JavaScript获取Asp.net服务器端控件CheckBoxList的选中值数组
- JS获取鼠标选中的文字
- 用JavaScript获取Asp.net服务器端控件CheckBoxList的选中值数组
- JavaScript取得gridview中获取checkbox选中的值
- Javascript获取select的选中值和选中文本
- 用JavaScript获取页面上被选中的文字的技巧