整体需要实现效果如下
以下可以实现 标记 选中 字符串
<html>
<head>
<script>
var $_text = '';
(function(){
document.onmousemove = function(){$_text = document.selection ? document.selection.createRange().text : window.getSelection(); }
document.onmouseup = function(){if($_text!='')alert($_text)}
})()
</script>
</head>
<body>
<div>hello world</div>
check this simple example out
</body>
</html>
以下方法可得到 当前选中的小标
window.getSelection() ;