资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
javascript 实现划词标记划词搜索功能
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>javascript实现划词标记划词搜索功能 </title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3CSCRIPT%20language%3Djavascript%3E%20%0D%0A%3C!--%20%0D%0Adocument.body.onload%3Dadddiv%3B%20%0D%0Adocument.onmousedown%3Drecordobj%3B%20%0D%0Adocument.ondblclick%3Ddbclick%3B%20%0D%0Adocument.onmouseup%3Dshowselect%3B%20%0D%0Avar%20starobj%2Cisdb%3Dfalse%2Callow%3Dtrue%3B%20%0D%0Afunction%20isallow()%20%0D%0A%7B%20%0D%0Aif(allow)%7B%20%0D%0Aallow%3Dfalse%3B%20%0D%0Aalert('is%20closed')%3B%20%0D%0A%7D%20%0D%0Aelse%7B%20%0D%0Aallow%3Dtrue%3B%20%0D%0Aalert('is%20opend')%3B%20%0D%0A%7D%20%0D%0A%7D%20%0D%0Afunction%20dbclick()%20%0D%0A%7B%20%0D%0Aisdb%3Dtrue%3B%20%0D%0A%7D%20%0D%0Afunction%20recordobj()%20%0D%0A%7B%20%0D%0Astarobj%3Devent.srcElement%3B%20%0D%0A%7D%20%0D%0Afunction%20showselect()%20%7B%20%0D%0Avar%20str%3D%22%22%3B%20%0D%0Aif(event.srcElement.tagName!%3D%22A%22%26%26event.srcElement.tagName!%3D%22INPUT%22%26%26event.srcElement%3D%3Dstarobj%26%26!isdb%26%26allow)%20%0D%0A%7B%20%0D%0Avar%20oText%3Ddocument.selection.createRange()%3B%20%0D%0Aif(oText.text.length%3E0)%20%0D%0A%7B%20%0D%0Astr%3DoText.text%3B%20%0D%0AoText.text%3D%22BuB%22%2BoText.text%2B%22EuE%22%3B%20%0D%0A%7D%20%0D%0A%0D%0AoText.select()%3B%20%0D%0Aevent.srcElement.innerHTML%3Devent.srcElement.innerHTML.replace(%22BuB%22%2C%22%3Cu%20style%3D'FONT-WEIGHT%3A%20bold%3BCOLOR%3A%20%23ff3366'%3E%22).replace(%22EuE%22%2C%22%3C%2Fu%3E%22)%3B%20%0D%0A%7D%20%0D%0Asearchgoogle(str)%20%0D%0Aisdb%3Dfalse%3B%20%0D%0A%7D%20%0D%0Afunction%20searchgoogle(str)%20%0D%0A%7B%20%0D%0Avar%20obj%3Ddocument.getElementById(%22searchgoogle%22)%3B%20%0D%0Aif(str.length%3E0)%20%0D%0A%7B%20%0D%0Aobj.style.display%3D%22block%22%3B%20%0D%0Aobj.style.position%3D%22absolute%22%3B%20%0D%0Aobj.style.zindex%3D999%3B%20%0D%0Aobj.style.posTop%3Ddocument.body.scrollTop%2Bevent.y-25%3B%20%0D%0Aobj.style.posLeft%3Ddocument.body.scrollLeft%2Bevent.x%2B5%3B%20%0D%0Aobj.style.widht%3D80%3B%20%0D%0Aobj.innerHTML%3D%22%3Ca%20target%3D_blank%20href%3Dhttp%3A%2F%2Fwww.google.com%2Fsearch%3Fie%3Dgbk%26oe%3Dgbk%26q%3D%22%2Bstr%2B%22%20style%3D'BORDER-RIGHT%3A%20royalblue%20thin%20solid%3B%20BORDER-TOP%3A%20royalblue%20thin%20solid%3B%20FONT-WEIGHT%3A%20bold%3B%20BORDER-LEFT%3A%20royalblue%20thin%20solid%3B%20CLIP%3A%20rect(auto%20auto%20auto%20auto)%3B%20COLOR%3A%20%23ffffff%3B%20BORDER-BOTTOM%3A%20royalblue%20thin%20solid%3B%20BACKGROUND-COLOR%3A%20inactivecaption%3B%20TEXT-DECORATION%3A%20none'%3E%E6%90%9C%E7%B4%A2%E7%9B%B8%E5%85%B3%3C%2Fa%3E%22%3B%20%0D%0A%7D%20%0D%0Aelse%20%0D%0A%7B%20%0D%0Aobj.style.display%3D%22none%22%3B%20%0D%0A%7D%20%0D%0A%7D%20%0D%0Afunction%20adddiv()%20%0D%0A%7B%20%0D%0Avar%20mobj%20%3D%20document.createElement(%22div%22)%3B%20%0D%0Amobj.id%3D%22searchgoogle%22%3B%20%0D%0Adocument.body.appendChild(mobj)%3B%20%0D%0A%7D%20%0D%0A%2F%2F--%3E%20%0D%0A%3C%2FSCRIPT%3E"> <INPUT type="button" onclick="isallow()" value="关闭/打开划词功能"> <p>管理资源吧是一个专业的收集各类脚本学习资料的网站,尽量修正错误打造精品脚本类学习网站,我们为大家游戏脚本资源,源码,软件,asp,php,javascript等编程资料,是网页制作,网络编程,网站建设人士的聚集场所。</p> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
在页面中加上这串代码就行了,同时还有搜索功能。
教程首页
更多教程