var xml_a; //xml对象 var pltsPop=null; var pltsoffsetX = 10; // 弹出窗口位于鼠标左侧或者右侧的距离;3-12 合适 var pltsoffsetY = 10; // 弹出窗口位于鼠标下方的距离;3-12 合适 var pltsPopbg="#FFFFEE"; //背景色 var pltsPopfg="#111111"; //前景色 var pltsTitle=""; var pltsWord=""; var MouseX=0; var MouseY=0; var styles="\r\n"; var url_a="http://www.vtte.com/htmlfiles/common/getword.php"; var pltsDiv=""; function pltsinits() { document.onmouseover = plts; document.onmousemove = moveToMouseLoc; } function plts() { pltsPop=pltsWord; pltsTipLayerOBJ=document.getElementById("pltsTipLayer"); if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined") { pltsTipLayerOBJ.style.left=-1000; pltsTipLayerOBJ.style.display=''; var Msg=pltsPop.replace(/\n/g,"
"); Msg=Msg.replace(/\0x13/g,"
"); Msg=Msg.replace(/\r/g,"
"); var re=/\{(.[^\{]*)\}/ig; if(!re.test(Msg))pltsTitle="随身字典(vtte.com)"; else{ re=/\{(.[^\{]*)\}(.*)/ig; pltsTitle=Msg.replace(re,"$1")+" "; re=/\{(.[^\{]*)\}/ig; Msg=Msg.replace(re,""); Msg=Msg.replace("
","");} //var attr=(document.location.toString().toLowerCase().indexOf("list.asp")>0?"nowrap":""); var content = '
'+ ''+ ''+ ''+ '

'+pltsTitle+'

'+Msg+'
'; pltsTipLayerOBJ.innerHTML=content; toolTipTalbe.style.width=Math.min(pltsTipLayerOBJ.clientWidth,document.body.clientWidth/2.2); moveToMouseLoc(); return true; } else { pltsTipLayerOBJ.innerHTML=''; pltsTipLayerOBJ.style.display='none'; return true; } } function hidDiv(e) //隐藏层 { pltsTipLayerOBJ=document.getElementById("pltsTipLayer"); if (_dict_is_ie) o=event.srcElement; else o=e.srcElement; if (o.id.indexOf('plts')>=0) //如果是在层里面则不隐藏 { return; } pltsTipLayerOBJ.innerHTML=''; pltsTipLayerOBJ.style.display='none';9 return true; } function moveToMouseLoc() //移动提示层 { pltsTipLayerOBJ=document.getElementById("pltsTipLayer"); if(pltsTipLayerOBJ.innerHTML=='')return true; var popHeight=pltsTipLayerOBJ.clientHeight; var popWidth=pltsTipLayerOBJ.clientWidth; //alert (document.body.clientHeight); //alert ("pltsoffsetY+popHeight:"+(pltsoffsetY+popHeight)+"\ndocument.body.clientHeight-MouseY:"+(document.body.clientHeight-MouseY)); if ((pltsoffsetY+popHeightdocument.body.clientWidth) //作用判断 { popLeftAdjust=-popWidth-pltsoffsetX*2; topleft.style.display="none"; botleft.style.display="none"; topright.style.display=""; botright.style.display=""; } else { popLeftAdjust=0; topleft.style.display=""; botleft.style.display=""; topright.style.display="none"; botright.style.display="none"; } //pltsTipLayerOBJ.style.left=MouseX+pltsoffsetX+document.body.scrollLeft+popLeftAdjust; //pltsTipLayerOBJ.style.top=MouseY+pltsoffsetY+document.body.scrollTop+popTopAdjust; //alert ("pltsoffsetY:"+pltsoffsetY+"\ndocument.documentElement.scrollTop:"+document.documentElement.scrollTop+"\npopTopAdjust:"+popTopAdjust+"\ndocument.body.clientHeight:"+document.body.clientHeight); pltsTipLayerOBJ.style.left=MouseX+pltsoffsetX+document.body.scrollLeft+popLeftAdjust; pltsTipLayerOBJ.style.top=MouseY+document.documentElement.scrollTop+popTopAdjust; return true; } function getword() //从服务器取得word信息 { var word=""; word=_dictGetSel(); //alert (word); if (_dict_is_ie) { MouseX = window.event.clientX; MouseY = window.event.clientY; } else { MouseX= arguments[0].pageX; MouseX= arguments[0].pageY; } //alert (MouseX); //下面这句用于将word类型转换为string word=""+word; if(_dict_is_ie) word=word.replace(/^\s*|\s*$/g,""); if (word=="" || word.length !=1) return true; json_data={ word: word }; /** * 临时禁用 $.ajax({ //timeout:5000, type: "POST", url: url_a, data:json_data, error:function(XMLHttpRequest, textStatus, errorThrown) { //alert (XMLHttpRequest.responseText); //"发生错误:textStatus--"+textStatus+";errorThrown--"+ alert ("发生错误:\n textStatus:"+textStatus+";\n errorThrown:"+errorThrown+";\n 服务器返回信息:\n "+XMLHttpRequest.responseText+"\n "); return ; }, success:function (xml) { processRequest_getword(xml); } }); **/ $.getJSON(url_a+"?word="+encodeURIComponent(word)+"&callback=?", function (data) { //alert (data.jieshi); if (data.errcode==0) { pltsWord=data.jieshi; plts(); } else { alert ("取字典信息出错:\n"+data.errmsg); return; } }); } function _dictGetSel() { if (window.getSelection) return window.getSelection(); else if (document.getSelection) return document.getSelection(); else if (document.selection) return document.selection.createRange().text; else return ''; } function processRequest_getword(xml) //处理服务器返回信息 { tabstr=""; if (xml.xml=="") { return false; } errcode=$("root",xml).attr("errcode"); if (errcode != 0) { tabstr="出现错误:\n"+$("root",xml).attr("errmsg"); alert (tabstr); } else { pltsWord=$("root",xml).attr("jieshi"); } plts(); } //document.write (styles); //document.write(""); if (typeof(window.jQuery)=="undefined") { //var jsstr="