samungtered 2009-06-08 20:38
浏览 286
已采纳

如何在jsp页面实现类似于金山词霸的划词功能

如何在jsp页面实现类似于金山词霸的划词功能

详细说明:
jsp页面显示的一些关键字段信息列表
然后我需要选择某个字段能够通过鼠标划词显示其具体的信息
类似于金山词霸的划词功能怎么实现?

  个人想到的肯定用js来实现
 有做过的JE友麻烦指点下,,,谢谢

[b]问题补充:[/b]
我要的是 划词后 根据划词部分的内容作为条件去数据表中拿旗整条记录的信息

你给我的我测试过 是用到Google的serach
谢谢你的代码
[b]问题补充:[/b]
我想可以通过DWR来实现 从数据表取数据进行显示
yougame的代码和 第一位的相同
有没有自己实现过类似功能的
Google的 我很怀疑.....

  • 写回答

4条回答 默认 最新

  • wanghaolovezlq 2009-06-08 22:40
    关注

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


    Untitled Document


    <!-- document.body.onload=adddiv; document.onmousedown=recordobj; document.ondblclick=dbclick; document.onmouseup=showselect; var starobj,isdb=false,allow=true; function isallow() { if(allow){ allow=false; alert('is closed'); } else{ allow=true; alert('is opend'); } } function dbclick() { isdb=true; } function recordobj() { starobj=event.srcElement; } function showselect() { var str=""; if(event.srcElement.tagName!="A"&&event.srcElement.tagName!="INPUT"&&event.srcElement==starobj&&!isdb&&allow) { var oText=document.selection.createRange(); if(oText.text.length>0) { str=oText.text; oText.text="BuB"+oText.text+"EuE"; } oText.select(); event.srcElement.innerHTML=event.srcElement.innerHTML.replace("BuB","<u style='FONT-WEIGHT: bold;COLOR: #ff3366'>").replace("EuE","</u>"); } searchgoogle(str) isdb=false; } function searchgoogle(str) { var obj=document.getElementById("searchgoogle"); if(str.length>0) { obj.style.display="block"; obj.style.position="absolute"; obj.style.zindex=999; obj.style.posTop=document.body.scrollTop+event.y-25; obj.style.posLeft=document.body.scrollLeft+event.x+5; obj.style.widht=80; obj.innerHTML="<a target=_blank href=http://www.google.com/search?ie=UTF-8&oe=UTF-8&q="+str+" style='BORDER-RIGHT: royalblue thin solid; BORDER-TOP: royalblue thin solid; FONT-WEIGHT: bold; BORDER-LEFT: royalblue thin solid; CLIP: rect(auto auto auto auto); COLOR: #ffffff; BORDER-BOTTOM: royalblue thin solid; BACKGROUND-COLOR: inactivecaption; TEXT-DECORATION: none'>Search It!</a>"; } else { obj.style.display="none"; } } function adddiv() { var mobj = document.createElement("div"); mobj.id="searchgoogle"; document.body.appendChild(mobj); } //-->

    qrasfdasfasfdasfsafasdfsafsafasdfasdfasd



    在页面中加上这串代码就行了,同时还有搜索功能。演示效果就请看本BLOG页面上用鼠标划选文字的效果。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面