选择文本事件
来源:互联网 发布:做淘宝推广工资怎么样 编辑:程序博客网 时间:2024/05/22 07:05
<!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>
<title>选择事件</title>
</head>
<body>
武汉
<div><span>湖北</span></div>
<div><span>中国</span></div>
</body>
<script type="text/javascript">
var K = K || {};
K.SelectEvent = function(e) {
var q = K.GetSelectText();
if ('' == q) return true;
alert(q);
};
K.GetSelectText = function() {
var q = '';
try {
if (window.getSelection) {
q = window.getSelection();
} else if (document.getSelection) {
q = document.getSelection();
} else if (document.selection) {
q = document.selection.createRange().text;
} else {
q = '';
}
q = q.toString();
q = q.replace(/((^/s*)|([/n/t/r]+)|(/s*$))/g, '');
if (q.replace(/[^/x00-/xff]/g, "**").length > 15) {
return '';
q = q.substr(0, 15);
}
} catch(e) {}
return q;
};
if (document.addEventListener) {
document.addEventListener("mouseup", K.SelectEvent, true);
} else if (document.attachEvent) {
document.attachEvent("onmouseup", K.SelectEvent);
} else {}
</script>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>选择事件</title>
</head>
<body>
武汉
<div><span>湖北</span></div>
<div><span>中国</span></div>
</body>
<script type="text/javascript">
var K = K || {};
K.SelectEvent = function(e) {
var q = K.GetSelectText();
if ('' == q) return true;
alert(q);
};
K.GetSelectText = function() {
var q = '';
try {
if (window.getSelection) {
q = window.getSelection();
} else if (document.getSelection) {
q = document.getSelection();
} else if (document.selection) {
q = document.selection.createRange().text;
} else {
q = '';
}
q = q.toString();
q = q.replace(/((^/s*)|([/n/t/r]+)|(/s*$))/g, '');
if (q.replace(/[^/x00-/xff]/g, "**").length > 15) {
return '';
q = q.substr(0, 15);
}
} catch(e) {}
return q;
};
if (document.addEventListener) {
document.addEventListener("mouseup", K.SelectEvent, true);
} else if (document.attachEvent) {
document.attachEvent("onmouseup", K.SelectEvent);
} else {}
</script>
</html>
- 选择文本事件
- 选择文本触发事件
- 文本选择
- 文本事件
- Jquery操作select获取当前选择项的文本及事件绑定
- ueditor加选择改变事件监听,便于对百度富文本编辑器做个性开发
- 选择文本ff/ie
- 鼠标选择文本
- JTextPane 选择文本
- javascript 选择文本
- QTextEdit选择文本
- js 禁止选择文本
- VIM选择文本块
- js选择部分文本
- 文本编辑器的选择
- VIM选择文本块
- Chromium文本选择放大镜
- QTextEdit选择文本
- C#编码规范Version 2.32(二)
- GSM小区复用模式
- 感恩10大事件回顾
- 自己封装了一个取得电脑信息及关机相关操作的类
- Euclid_s Game实现(c++)欧基里得游戏
- 选择文本事件
- 介绍JSON
- C#编码规范Version 2.32(四)
- XPath 节点
- XPath 语法
- 巴尔默当上微软当家人的首次采访!
- 自己封装的注册表操作类
- 已存在的情况下创建/影像复制该文件"是由什么导致的
- 在子更新时,同步更新相应frame.就是在更新本frame时,找到上级对象的相应的frame调用对应的location的reload()方法,完成同步更新。