ie页面上鼠标取词?

TomyGuan 2006-09-25 03:29:31
类似于金山词霸的鼠标取词?怎麼做呢?thx!
...全文
335 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
web_php 2006-09-27
  • 打赏
  • 举报
回复
好东西,收藏
TomyGuan 2006-09-26
  • 打赏
  • 举报
回复
to ;fantiny(乐于助人的菜鸟回归) (

獲得字詞後是怎樣分析的呢?
JK_10000 2006-09-26
  • 打赏
  • 举报
回复
请查参考书:textRange property :text

基本问题,查参考书就能当别人的师弟,
查都懒得查就问别人,那永远当别人的学生

----------------
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JK:支持民族工业,尽量少买X货</title>
</head>

<body onmousemove="mouseMoveToSelectFun(this)" >
<input id=aaa >

Ctrl + 鼠标 = 选中<br/>
<br/>
Would you like bananas ?<br/>
Would you like bananas ?<br/>
Would you like bananas ?<br/>

</body>

</html>
<script language=javascript>
function mouseMoveToSelectFun(obj)
{
try{
if(!event.ctrlKey) return false;
var theRange=obj.createTextRange();
theRange.moveToPoint(event.x,event.y);
theRange.moveStart("word",-1);
theRange.moveEnd("word",1);
theRange.select();
aaa.value=theRange.text;
}
catch(e)
{
}
}

</script>
fantiny 2006-09-26
  • 打赏
  • 举报
回复
显示的图层可以用lantersen的方法。
获取数据可以用xmlhttp的方式从服务器上获取。
不过为了性能,可以预读出来放在javascript数组里。
lantersen 2006-09-26
  • 打赏
  • 举报
回复
你可以:
1:把它放到复制板当中去clipboardData,
2:再从中去取数据window.clipboardData.getData("Text");
3:进行后续处理;
chaircat 2006-09-25
  • 打赏
  • 举报
回复
映像中某本JS的教材上面有...
lantersen 2006-09-25
  • 打赏
  • 举报
回复
只能是这样,简单的模拟:
<script language="javascript" type="text/javascript">
document.onmousemove = mouseMove;

function showIt(obj)
{
var con = ['你好','世界','You','Good'];
var reg = /\d+/;
var id = obj.id.match(reg);
var t = document.getElementById("con");
t.innerText = con[parseInt(id)];
}

function hiddenIt()
{
document.getElementById('con').visibility='hidden';
}

function mouseMove()
{
var t = document.getElementById("con");
t.style.left = event.x-5;
t.style.top = event.y-8;
}
</script>
</HEAD>

<BODY>
<div id="pnode" style="position:absolute;z-index:5">
<div id="con" style="border:1px solid #CCFFFF;background:#FFFFCC;color:#55A69A;position:relative;z-index:10;width:60px;height:60px;"></div>
<span id="w0" onmouseover="showIt(this);" onmouseout="hiddenIt();" style="width:50px;">Hello</span>
<span id="w1" onmouseover="showIt(this);" onmouseout="hiddenIt();" style="width:50px;">World</span>
<span id="w2" onmouseover="showIt(this);" onmouseout="hiddenIt();" style="width:50px;">你</span>
<span id="w3" onmouseover="showIt(this);" onmouseout="hiddenIt();" style="width:50px;">好</span>
</div>
</BODY>
</HTML>
RexZheng 2006-09-25
  • 打赏
  • 举报
回复
楼上写的这个不错 :)
fantiny 2006-09-25
  • 打赏
  • 举报
回复
不需要Ctrl 忘了删掉注释
fantiny 2006-09-25
  • 打赏
  • 举报
回复
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>FTS:支持民族工业,尽量少买X货</title>
</head>

<body onmousemove="mouseMoveToSelectFun(this)" >
Ctrl + 鼠标 = 选中<br>
<br>
Would you like bananas ?<br>
Would you like bananas ?<br>
Would you like bananas ?<br>

</body>

</html>
<script language=javascript>
function mouseMoveToSelectFun(obj)
{
var theRange=obj.createTextRange();
theRange.moveToPoint(event.x,event.y);
theRange.expand("word");
theRange.select();
}

</script>
rob123 2006-09-25
  • 打赏
  • 举报
回复
mark!
ttzhangzhiwei 2006-09-25
  • 打赏
  • 举报
回复
up
JK_10000 2006-09-25
  • 打赏
  • 举报
回复
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JK:支持民族工业,尽量少买X货</title>
</head>

<body onmousemove="mouseMoveToSelectFun(this)" >
Ctrl + 鼠标 = 选中<br>
<br>
Would you like bananas ?<br>
Would you like bananas ?<br>
Would you like bananas ?<br>

</body>

</html>
<script language=javascript>
function mouseMoveToSelectFun(obj)
{
if(!event.ctrlKey) return false;
var theRange=obj.createTextRange();
theRange.moveToPoint(event.x,event.y);
theRange.moveStart("word",-1);
theRange.moveEnd("word",1);
theRange.select();
}

</script>
laofu568 2006-09-25
  • 打赏
  • 举报
回复
MARK!等结果,我也学习一下~~
TomyGuan 2006-09-25
  • 打赏
  • 举报
回复
有一些提示嗎?
是是非非 2006-09-25
  • 打赏
  • 举报
回复
…………这难度也太大了

87,917

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧