JavaScript實(shí)現(xiàn)簡單Tip提示框效果

字號:


    這篇文章主要介紹了JavaScript實(shí)現(xiàn)簡單Tip提示框效果,涉及JavaScript響應(yīng)鼠標(biāo)事件針對頁面元素動(dòng)態(tài)操作的相關(guān)技巧,需要的朋友可以參考下
    本文實(shí)例講述了JavaScript實(shí)現(xiàn)簡單Tip提示框效果。分享給大家供大家參考,具體如下:
    // JavaScript Document
    document.write("<div id='tip' style='position:absolute; width:300px; z-index:1; background-color: #ffffff; border: 1px solid gray; overflow: visible;visibility: hidden;font-size:12px;padding:12px;color:#333333'></div>")
    function showtip(w){
    var x=event.x;
    var y=event.y;
    tip.innerHTML=w;
    tip.style.visibility="visible";
    tip.style.left=x+10;
    tip.style.pixelTop=y+document.body.scrollTop+10;
    }
    function hidetip(){
    tip.style.innerHTML=""
    tip.style.visibility="hidden";
    }
    以上另存為: showtip.js
    <table cellspacing="0" cellpadding="0" background="#F7F7F0">
    <tr height="25">
    <td background="images/line-dot.gif" height="20"><IMG height="5" src="images/dot2.gif" width="5">
    <a
    onmousemove="showtip('<b>標(biāo)題:</b><br>畢業(yè)女生 自信更在包裝外<br>')"
    onmouseout=hidetip()
    href='Common/NewsDetails.aspx?id=1035'
    target=_blank>
    畢業(yè)女生 自信更在包裝外
    </a>
    </td>
    </tr>
    <tr>
    <td background="images/point_h.gif" height="1"></td>
    </tr>
    </table>
    希望本文所述對大家JavaScript程序設(shè)計(jì)有所幫助。