⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tooltip_js.htc

📁 一款由JAVA开发的宝库游戏源代码
💻 HTC
📖 第 1 页 / 共 2 页
字号:
////-----------------------------------------------------------------------------function DetachElement(){    oDetach = eval('window.document.all["' + oTipElem + '"]');        if (oDetach.length != null && oDetach.length > 1)    {        for (i=0; i<oDetach.length; i++)        {            oDetach(i).detachEvent("onmouseover", DoMouseOverElem);            oDetach(i).detachEvent("onmouseout", DoMouseOutElem);            oDetach(i).detachEvent("onpropertychange", DoPropChangeElem);        }    }        else    {        oDetach.detachEvent("onmouseover", DoMouseOverElem);        oDetach.detachEvent("onmouseout", DoMouseOutElem);        oDetach.detachEvent("onpropertychange", DoPropChangeElem);    }}//+----------------------------------------------------------------------------////  Function:       AttachElement////  Description:    Attaches onmouseover, onmouseout, and onproperty change//                  to the element the tooltip is assigned to (via the element//                  property).  If the element is a collection, the members//                  of the collection are enumerated.  If the element does//                  not exist, an error is returned.////  Arguments:      none////  Returns:        false if the element does not exist////-----------------------------------------------------------------------------function AttachElement(){    //    //  Set a variable equal to the object represented by the ID specified    //  in the tooltip element.    //    var oAttach = eval('window.document.all["' + element.element + '"]');    //  If the element does not exist, return an error    if (oAttach == null)    {        ReturnError("Element specified in Tooltip is undefined");        return false;    }        //    //  If the element is a collection (more than one element with the same    //  ID), the events are attached to each member of the collection.    //    else if (oAttach.length != null && oAttach.length > 1)    {        for (i=0; i<oAttach.length; i++)        {            oAttach(i).attachEvent("onmouseover", DoMouseOverElem);            oAttach(i).attachEvent("onmouseout", DoMouseOutElem);            oAttach(i).title = "";            if (oAttach(i).tagName.toLowerCase() == "img") oAttach(i).alt = "";            oAttach(i).attachEvent("onpropertychange", DoPropChangeElem);        }    }        //  Otherwise, the events are attached to the single element.    else    {        oAttach.attachEvent("onmouseover", DoMouseOverElem);        oAttach.attachEvent("onmouseout", DoMouseOutElem);        oAttach.title = "";        if (oAttach.tagName.toLowerCase() == "img") oAttach.alt = "";        oAttach.attachEvent("onpropertychange", DoPropChangeElem);    }        //  Set the variable to track the element's ID    oTipElem = element.element;}//+----------------------------------------------------------------------------////  Function:       ShowTip////  Description:    Method to show tooltip.////  Arguments:      none////  Returns:        false if bShowing is false (this prevents the ShowTip from//                      repeatedly being called by mousing over the element//                      and the tooltip).////-----------------------------------------------------------------------------function ShowTip(){    if (!bShowing) return false;        var oBody = window.document.body;            //  Set the horizontal position of the tooltip    if (iOffsetX + iOffsetW > oBody.clientWidth)	{		style.left = oBody.clientWidth + oBody.scrollLeft - iOffsetW;	}    else style.left = iOffsetX + oBody.scrollLeft;        //  Set the vertical position of the tooltip    if (iOffsetY + iOffsetH > oBody.offsetHeight)    {		style.top = oBody.clientHeight + oBody.scrollTop - iOffsetH;    }    else style.top = iOffsetY + oBody.scrollTop;        //  Make the tooltip visible    style.display = "block";        //  Fire the onshow event    show.fire();        //  Start the timer to turn off the tooltip (call HideTip())    setTimeout(uniqueID + ".HideTip()", duration * 1000);}//+----------------------------------------------------------------------------////  Function:       HideTip////  Description:    Method to hide tooltip.////  Arguments:      none////  Returns:        false if the user has moved from the element to the tooltip//                      and the avoidMouse property is set to false.////-----------------------------------------------------------------------------function HideTip(){    if (bOverTip && (avoidMouse == "false" || avoidMouse == false)) return false;    bShowing = false;        //  Hide the tooltip    style.display = "none";        //  Fire the onhide event    hide.fire();}//+----------------------------------------------------------------------------////  Function:       DoMouseOverElem////  Description:    Calls the ShowTip() methods after the delay period (set by//                  the delay property) has expired.////  Arguments:      none////  Returns:        false if the mouse is returning from the tooltip////-----------------------------------------------------------------------------function DoMouseOverElem(){    //  If the mouse is coming back from the tooltip, return    if (window.event.fromElement == element) return false;    //  Base the position of the tooltip on the position of the mouse    iOffsetX = window.event.x - 10;    iOffsetY = window.event.y + 18;        //  Set tracking variable    bShowing = true;        //  Call ShowTip() after delay    if (delay != -1) setTimeout(uniqueID + ".ShowTip()", delay);}//+----------------------------------------------------------------------------////  Function:       DoMouseOutElem////  Description:    Calls the HideTip() method after a 200ms delay (currently//                  hard-coded).////  Arguments:      none////  Returns:        nothing////-----------------------------------------------------------------------------function DoMouseOutElem(){    //  Call HideTip after a 200ms delay    setTimeout(uniqueID + ".HideTip()", 200);}//+----------------------------------------------------------------------------////  Function:       DoMouseOverTip////  Description:    Sets the variable to track if the mouse is over the tooltip//                  itself.  This assists in the process of allowing the user//                  to mouse over the tooltip itself, in the case where it//                  contains links, etc.  Note, this function is not called if//                  the avoidMouse property is set to true.////  Arguments:      none////  Returns:        nothing////-----------------------------------------------------------------------------function DoMouseOverTip(){    oCurrTip = window.event.fromElement;        bOverTip = true;}//+----------------------------------------------------------------------------////  Function:       DoMouseOutTip////  Description:    This function occurs on the mouseout event of the tooltip.//                  When the user mouses out of the tooltip, the HideTip()//                  method is called. As in the DoMouseOverTip() function above,//                  this function is not called if the avoidMouse Property is //                  set to true.////  Arguments:      none////  Returns:        false if the srcElement is inside of the tooltip//                  false if the mouse is returning to the tip element////-----------------------------------------------------------------------------function DoMouseOutTip(){    //    //  If the element causing the mouseout is inside the tooltip container,    //  don't hide the tooltip    //    if (element.contains(window.event.toElement)) return false;        //  If the mouse is returning to the tip element, don't hide the tooltip    if (window.event.toElement == oCurrTip)    {        bOverTip = false;        oCurrTip = null;        return false;    }    bOverTip = false;    HideTip();}//+----------------------------------------------------------------------------////  Function:       ReturnError////  Description:    Fires the error event, along with a descriptive text//                  message.////  Arguments:      sMsg - descriptive text message////  Returns:        nothing ////-----------------------------------------------------------------------------function ReturnError(sMsg){    var oEvent = createEventObject();    oEvent.setAttribute("error", sMsg);    error.fire(oEvent);}</SCRIPT>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -