如何实现划词取字或者光标停留取字? 我找到相关的, 划词搜索功能http://net.stuun.com/web/Javascript/44673.html不过它不支援 Firefox, 只支援IE有谁可以改成支持大部份浏览器 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 支持IE6 和 FF3.0.7<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body> <SCRIPT language=javascript><!--window.onload=adddiv;document.onmousedown=function(e){recordobj(e)};document.ondblclick=dbclick;document.onmouseup=function(e){showselect(e)};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(e){ e = e || window.event; starobj = e.srcElement || e.target;}function showselect(e){ e = e || window.event; theobj = e.srcElement || e.target; var str="[^.]"; if(theobj.tagName != "A" && theobj.tagName != "INPUT" && theobj == starobj && !isdb && allow) { if(document.all){ var oText = document.selection.createRange(); if(oText.text.length>0){ str=oText.text; oText.text = oText.text; } oText.select(); }else{ str = document.getSelection(); } theobj.innerHTML = theobj.innerHTML .replace(new RegExp(str,"gi"),"<u style='FONT-WEIGHT: bold;COLOR: #ff3366'>" + str + "</u>"); } searchgoogle(str,e); isdb=false;}function searchgoogle(str,e){ var obj = document.getElementById("searchgoogle"); if(str.length>0){ obj.style.display="block"; obj.style.position="absolute"; obj.style.zIndex=999; obj.style.top=(document.body || document.documentElement).scrollTop + (e.y || e.pageY) - 25 + "px"; obj.style.left=(document.body || document.documentElement).scrollLeft + (e.x || e.pageX) + 5 + "px"; 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 if(obj){ obj.style.display = "none"; }}function adddiv(){ var mobj = document.createElement("div"); mobj.id="searchgoogle"; (document.body || document.documentElement).appendChild(mobj);}</SCRIPT><INPUT type="button" onclick="isallow()" value="关闭/打开划词功能"> <p>qrasfdasfasfdasfsafasdfsafsafasdfasdfasd</p> </body> </html> 简单的json问题 点击添加按钮没反应也就是说调用不到DispatchAction中的add方法我是新手谢谢你们了 谢谢 javascript如何实现在frameset中跨域访问 PHP中如何引进javascript中的内容 请问用什么方式才能在javascript语言中调用动态链接库? 用JAVASCRIPT 生成类似左边那样的动态菜单? 子窗口怎样得到父窗口的值??急 怎样全部选中select中的值? 那里有好的javascript教程下载? 谁会html+js的?(vbs也可以)帮我弄一个一打开就执行本机指定exe的空网页,OK? 急问一个菜鸟问题 请教个动态创建控件的问题
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body> <SCRIPT language=javascript>
<!--
window.onload=adddiv;
document.onmousedown=function(e){recordobj(e)};
document.ondblclick=dbclick;
document.onmouseup=function(e){showselect(e)};
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(e){
e = e || window.event;
starobj = e.srcElement || e.target;
}
function showselect(e){
e = e || window.event;
theobj = e.srcElement || e.target;
var str="[^.]";
if(theobj.tagName != "A" && theobj.tagName != "INPUT" && theobj == starobj && !isdb && allow) {
if(document.all){
var oText = document.selection.createRange();
if(oText.text.length>0){
str=oText.text;
oText.text = oText.text;
}
oText.select();
}else{
str = document.getSelection();
}
theobj.innerHTML = theobj.innerHTML
.replace(new RegExp(str,"gi"),"<u style='FONT-WEIGHT: bold;COLOR: #ff3366'>" + str + "</u>");
}
searchgoogle(str,e);
isdb=false;
}
function searchgoogle(str,e){
var obj = document.getElementById("searchgoogle");
if(str.length>0){
obj.style.display="block";
obj.style.position="absolute";
obj.style.zIndex=999;
obj.style.top=(document.body || document.documentElement).scrollTop + (e.y || e.pageY) - 25 + "px";
obj.style.left=(document.body || document.documentElement).scrollLeft + (e.x || e.pageX) + 5 + "px";
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 if(obj){
obj.style.display = "none";
}
}
function adddiv(){
var mobj = document.createElement("div");
mobj.id="searchgoogle";
(document.body || document.documentElement).appendChild(mobj);
}
</SCRIPT>
<INPUT type="button" onclick="isallow()" value="关闭/打开划词功能">
<p>qrasfdasfasfdasfsafasdfsafsafasdfasdfasd</p>
</body>
</html>