怎樣用腳本實現  檔鼠標移動到一行字或者一個圖片上
會顯示出一段提示文字内容  移開又沒了

解决方案 »

  1.   

    加入此jstooltip.js
    //alt,title 样式,配合样式表使用,页面引用此js即可
    /********** 文字提示信息样式 **********/
    //.tableBorder7
    //{width:800;solid; background-color: #fff;}
    //TD
    //{font-family: 宋体;font-size: 12px;line-height : 15px ;}
    //th
    //{background-color: #f7f7f7;color: #fff;font-size: 12px;font-weight:bold;}
    //th.th1
    //{background-color: #444;}
    //td.TableBody7    /*内容背景*/
    //{background-color: #f8f8f8;}
    /***************************************//*
    var postSubmited = false;
    function ctlent(obj) {
    if(postSubmited == false && (event.ctrlKey && window.event.keyCode == 13) || (event.altKey && window.event.keyCode == 83)) {
    if(this.document.input.topicsubmit) this.document.input.topicsubmit.disabled = true;
    if(this.document.input.replysubmit) this.document.input.replysubmit.disabled = true;
    if(this.document.input.editsubmit) this.document.input.editsubmit.disabled = true;
    postSubmited = true;
    this.document.input.submit();
    }
    }
    */
    var flag=false; 
    function DrawImage(ImgD){ 
    var image=new Image(); 
    image.src=ImgD.src; 
    if(image.width>0 && image.height>0){ 
    flag=true; 
    if(image.width>=518){ 
    ImgD.width=518; 
    ImgD.height=(image.height*518)/image.width; 
    }else{ 
    ImgD.width=image.width; 
    ImgD.height=image.height; 
    }  

    } function displayleft(obj,name)
    {
     LeftDiv=eval("document.all."+name)
       if (LeftDiv.style.display=="")
            {
            LeftDiv.style.display="none";
            
            }
       else
        {
         LeftDiv.style.display="";
         
        }
     }
     
     function displayleft1(obj,name)
    {
     upDiv=eval("document.all."+name)
       if (upDiv.style.display=="")
            {
            upDiv.style.display="none";
            
            }
       else
        {
         upDiv.style.display="";
         
        }
     }function showIntro(objID)
    {
    if (document.getElementById(objID).style.display == "none") {
    document.getElementById(objID).style.display = "";
    }else{
    document.getElementById(objID).style.display = "none";
    }
    }function winconfirm(confirmMSG,confirmURL){
    question = confirm(confirmMSG);
    if (question != "0"){
    window.location=confirmURL;
    }
    }function CopyText(obj) {
    ie = (document.all)? true:false
    if (ie){
    var rng = document.body.createTextRange();
    rng.moveToElementText(obj);
    rng.scrollIntoView();
    rng.select();
    rng.execCommand("Copy");
    rng.collapse(false);
    }
    }function UBBShowObj(strType,strID,strURL,intWidth,intHeight)
    {
    var varHeader="V";
    var tmpstr="";
    var bSwitch = false;
    bSwitch = document.getElementById(varHeader+strID).value;
    bSwitch =~bSwitch;
    document.getElementById(varHeader+strID).value = bSwitch;
    if(bSwitch){
    document.getElementById(strID).innerHTML = "影音文件源地址:<a href='"+strURL+"' target='_blank'>"+strURL+"</a>";
    }else{
    switch(strType.toUpperCase()){
    case "SWF":
    tmpstr="<object codeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='"+intWidth+"' height='"+intHeight+"'><param name='movie' value='"+strURL+"'><param name='quality' value='high'><param name='AllowScriptAccess' value='never'><embed src='"+strURL+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+intWidth+"' height='"+intHeight+"'>'"+strURL+"'</embed></OBJECT>";
    break;
    case "WMA":
    tmpstr="<object classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'  id='MediaPlayer' width='"+intWidth+"' height='"+intHeight+"'><param name='ShowStatusBar' value='-1'><param name='AutoStart' value='True'><param name='Filename' value='"+strURL+"'></object>";
    break;
    case "WMV":
    tmpstr="<object classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' width='"+intWidth+"' height='"+intHeight+"'><param name='ShowStatusBar' value='-1'><param name='AutoStart' value='Ture'><param name='Filename' value='"+strURL+"'></object>";
    break;
    case "RM":
    tmpstr="<object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' height='"+intHeight+"' id='Player' width='"+intWidth+"' viewastext><param name='_ExtentX' value='12726'><param name='_ExtentY' value='8520'><param name='AUTOSTART' value='0'><param name='SHUFFLE' value='0'><param name='PREFETCH' value='0'><param name='NOLABELS' value='0'><param name='CONTROLS' value='ImageWindow'><param name='CONSOLE' value='_master'><param name='LOOP' value='0'><param name='NUMLOOP' value='0'><param name='CENTER' value='0'><param name='MAINTAINASPECT' value='"+strURL+"'><param name='BACKGROUNDCOLOR' value='#000000'></object><br><object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' height='32' id='Player' width='"+intWidth+"' VIEWASTEXT><param name='_ExtentX' value='18256'><param name='_ExtentY' value='794'><param name='AUTOSTART' value='-1'><param name='SHUFFLE' value='0'><param name='PREFETCH' value='0'><param name='NOLABELS' value='0'><param name='CONTROLS' value='controlpanel'><param name='CONSOLE' value='_master'><param name='LOOP' value='0'><param name='NUMLOOP' value='0'><param name='CENTER' value='0'><param name='MAINTAINASPECT' value='0'><param name='BACKGROUNDCOLOR' value='#000000'><param name='SRC' value='"+strURL+"'></object>";
    break;
    case "QT":
    tmpstr="<embed src='"+strURL+"' autoplay='true' Loop='false' controller='true' playeveryframe='false' cache='false' scale='TOFIT' bgcolor='#000000' kioskmode='false' targetcache='false' pluginspage='http://www.apple.com/quicktime/'>";
    break;
    case "RA":
    tmpstr="<object classid='clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA' id='RAOCX' width='"+intWidth+"' height='"+intHeight+"'><param name='_ExtentX' value='6694'><param name='_ExtentY' value='1588'><param name='AUTOSTART' value='0'><param name='SHUFFLE' value='0'><param name='PREFETCH' value='0'><param name='NOLABELS' value='0'><param name='SRC' value='"+strURL+"'><param name='CONTROLS' value='StatusBar,ControlPanel'><param name='LOOP' value='0'><param name='NUMLOOP' value='0'><param name='CENTER' value='0'><param name='MAINTAINASPECT' value='0'><param name='BACKGROUNDCOLOR' value='#000000'><embed src='"+strURL+"' width='253' autostart='true' height='60'></embed></object>"
    }
    document.getElementById(strID).innerHTML = tmpstr;
    }
    }
      

  2.   


    function AutoSizeDIV(objID){
    var obj=document.getElementById(objID);
    if (obj.scrollHeight < obj.offsetHeight){
    obj.style.height = obj.scrollHeight+2;
    }
    }
    //文字提示信息
    <!--
    var pltsPop=null;
    var pltsoffsetX = 10;   // 弹出窗口位于鼠标左侧或者右侧的距离;3-12 合适
    var pltsoffsetY = 15;  // 弹出窗口位于鼠标下方的距离;3-12 合适
    var pltsPopbg="#cccccc"; //背景色
    var pltsPopfg="#111111"; //前景色
    var pltsTitle="";
    document.write('<div id=pltsTipLayer style="display: none;position: absolute; z-index:10001"></div>');
    function pltsinits()
    {
        document.onmouseover   = plts;
        document.onmousemove = moveToMouseLoc;
    }
    function plts()
    {  var o=event.srcElement;
        if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
        if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
        pltsPop=o.dypop;
        if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined")
        {
    pltsTipLayer.style.left=-1000;
    pltsTipLayer.style.display='';
    var Msg=pltsPop.replace(/\n/g,"<br>");
    Msg=Msg.replace(/\0x13/g,"<br>");
    var re=/\{(.[^\{]*)\}/ig;
    if(!re.test(Msg))pltsTitle="<font color=#ffffff>提示</font>";
    else{
      re=/\{(.[^\{]*)\}(.*)/ig;
         pltsTitle=Msg.replace(re,"$1")+" ";
      re=/\{(.[^\{]*)\}/ig;
      Msg=Msg.replace(re,"");
      Msg=Msg.replace("<br>","");}
      var attr=(document.location.toString().toLowerCase().indexOf("list.asp")>0?"nowrap":"");
            var content =
           '<table style="FILTER:alpha(opacity=90) shadow(color=#bbbbbb,direction=135);" id=toolTipTalbe border=0 width="300px"><tr><td width="100%"><table class=tableBorder7 cellspacing="0" cellpadding="0" style="width:100%">'+
           '<tr id=pltsPoptop ><th height=18 valign=bottom class=th1 ><b><p id=topleft align=left><font color=#ffffff>↖</font>'+pltsTitle+'</p><p id=topright align=right style="display:none">'+pltsTitle+'<font color=#ffffff>↗</font></b></th></tr>'+
           '<tr><td "+attr+" class=tablebody7 style="padding-left:10px;padding-right:10px;padding-top: 6px;padding-bottom:6px;line-height:135%">'+Msg+'</td></tr>'+
           '<tr id=pltsPopbot style="display:none"><th height=18 valign=bottom class=th1><b><p id=botleft align=left><font color=#ffffff>↙</font>'+pltsTitle+'</p><p id=botright align=right style="display:none">'+pltsTitle+'<font color=#ffffff>↘</font></b></th></tr>'+
           '</table></td></tr></table>';
            pltsTipLayer.innerHTML=content;
            toolTipTalbe.style.width=Math.min(pltsTipLayer.clientWidth,document.body.clientWidth/2.2);
            moveToMouseLoc();
            return true;
           }
        else
        {
         pltsTipLayer.innerHTML='';
           pltsTipLayer.style.display='none';
            return true;
        }
    }function moveToMouseLoc()
    {
    if(pltsTipLayer.innerHTML=='')return true;
    var MouseX=event.x;
    var MouseY=event.y;
    //window.status=event.y;
    var popHeight=pltsTipLayer.clientHeight;
    var popWidth=pltsTipLayer.clientWidth;
    if(MouseY+pltsoffsetY+popHeight>document.body.clientHeight)
    {
       popTopAdjust=-popHeight-pltsoffsetY*1.5;
       pltsPoptop.style.display="none";
       pltsPopbot.style.display="";
    }
     else
    {
        popTopAdjust=0;
       pltsPoptop.style.display="";
       pltsPopbot.style.display="none";
    }
    if(MouseX+pltsoffsetX+popWidth>document.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";
    }
    pltsTipLayer.style.left=MouseX+pltsoffsetX+document.body.scrollLeft+popLeftAdjust;
    pltsTipLayer.style.top=MouseY+pltsoffsetY+document.body.scrollTop+popTopAdjust;
       return true;
    }
    pltsinits();//-->
      

  3.   

    <input type=button value="ok" title="OK">
      

  4.   

    你要的估计只是简单的title而已
    就是在<tr> <td> 里面加 title = "字"
      

  5.   

    这个是对title的改写反正你存成js就可以用了
      

  6.   

    <div id="fff" title="标题:Test Title Clip&#xA;作者:cumtshine">fff</div>