?? tooltip_js.htc.html
字號:
<!-- ---------------------------------------------------------------------//// Copyright 1998 Microsoft Corporation. All Rights Reserved.//// File: tooltip_js.htc//// Description: This behavior allows web authors to add tooltips to any// element on the page. Any HTML can be included in the // tooltip, including images and CSS formatting. Web authors// can also control the placement and duration of the tooltip.////-------------------------------------------------------------------- --><PROPERTY NAME="avoidMouse" /><PROPERTY NAME="element" /><PROPERTY NAME="delay" /><PROPERTY NAME="duration" /><METHOD NAME="HideTip" /><METHOD NAME="ShowTip" /><EVENT NAME="onshow" ID="show" /><EVENT NAME="onhide" ID="hide" /><EVENT NAME="onerror" ID="error" /><ATTACH EVENT="ondocumentready" HANDLER="DoInit" /><SCRIPT LANGUAGE="jscript">//+----------------------------------------------------------------------------//// Global Variables////-----------------------------------------------------------------------------var bShowing; // Tracks if the tooltip is showingvar bOverTip; // Tracks if the mouse is over the tooltipvar iOffsetX; // Tracks the left position to show the tooltipvar iOffsetY; // Tracks the top position to show the tooltipvar oCurrTip; // Tracks the element that is left to move over the tooltipvar iOffsetW; // Tracks the width of the tooltipvar iOffsetH; // Tracks the height of the tooltipvar oTipElem; // Tracks the element property when AttachEvent is called. // This allows DetachEvent to undo the attached events // If the element property is changed at runtime.//+----------------------------------------------------------------------------//// Function: DoInit//// Description: Calls functions to initialize behavior. Attaches events// that are not attached using the <ATTACH> element to prevent// firing the events until the defaults are set and the// behavior is initialized.//// Arguments: none//// Returns: nothing////-----------------------------------------------------------------------------function DoInit(){ SetDefaults(); AttachElement(); attachEvent("onmouseover", DoMouseOverTip); attachEvent("onmouseout", DoMouseOutTip); attachEvent("onpropertychange", DoPropChangeTip);}//+----------------------------------------------------------------------------//// Function: SetDefaults//// Description: Called during the initialization of the behavior. Sets// the required settings for CSS properties and defaults for// regular CSS properties (the NormalDefault() function), and// attribute/properties.//// Arguments: none//// Returns: nothing////-----------------------------------------------------------------------------function SetDefaults(){ // CSS hard-coded defaults (required settings) style.position = "absolute"; style.visibility = "hidden"; // CSS Property Defaults NormalDefault('fontSize', '12', '8pt'); NormalDefault('fontFamily', 'Times New Roman', 'Arial'); NormalDefault('padding', '0px', '0 2 0 2'); NormalDefault('backgroundColor', 'transparent', '#ffffe7'); NormalDefault('borderStyle', 'none', 'solid'); NormalDefault('borderWidth', 'medium', '1px'); NormalDefault('borderColor', '#000000', 'black'); NormalDefault('color', '#000000', 'black'); style.width = GetWidth(); // Set the width by calling GetWidth() style.height = GetHeight(); // Set the height by calling GetHeight() style.display = "none"; style.visibility = "visible"; iOffsetW = parseInt(style.width); iOffsetH = parseInt(style.height); // Attribute | Property Defaults if (avoidMouse == null) avoidMouse = false; if (delay == null) delay = 500; if (duration == null) duration = 10;}//+----------------------------------------------------------------------------//// Function: NormalDefault//// Description: Sets the defaults for CSS properties by checking the// currentStyle and style of the object against the IE// default.//// Arguments: sCSSName - the CSS name of the property// sIEDefault - the IE standard default of the property// sDefault - the desired default of the property//// Returns: nothing////-----------------------------------------------------------------------------function NormalDefault(sCSSName, sIEDefault, sDefault){ if (currentStyle[sCSSName] == sIEDefault && (style[sCSSName] == "" || style[sCSSName] == null)) { style[sCSSName] = sDefault; }}//+----------------------------------------------------------------------------//// Function: DoPropChangeTip//// Description: If the element//// Arguments: none//// Returns: nothing////-----------------------------------------------------------------------------function DoPropChangeTip(){ var propertyName = window.event.propertyName; if (propertyName == "element") { DetachElement(); AttachElement(); }}//+----------------------------------------------------------------------------//// Function: DoPropChangeElem//// Description: If the ALT or TITLE property of the element the tooltip is// attached to are changed, this function prevents that change// and fires the error event.//// Arguments: none//// Returns: nothing////-----------------------------------------------------------------------------function DoPropChangeElem(){ var propertyName = window.event.propertyName.toLowerCase(); var srcElement = window.event.srcElement; if (propertyName == "title" || propertyName == "alt") { // Detach the propertychange event while the next steps are performed srcElement.detachEvent("onpropertychange", DoPropChangeElem); // Set ALT and TITLE to empty string srcElement.title = ""; srcElement.alt = ""; // Fire error event with message ReturnError("The " + propertyName + " property is disabled " + "when it is attached to the ToolTip behavior"); // Reattach the propertychange event. srcElement.attachEvent("onpropertychange", DoPropChangeElem); }}//+----------------------------------------------------------------------------//// Function: GetHeight//// Description: This function helps set the height of the tooltip, either// by grabbing the explicit value set on the page or by using// the getBoundingClientRect() method.//// Arguments: none//// Returns: currentStyle.height if currentStyle.height is not equal to// "auto" (which would likely signal it was not set by the// html page).// iHeight if currentStyle.height is equal to "auto". iHeight// is a value based on the getBoundingClientRect() method on// the tooltip object. ////-----------------------------------------------------------------------------function GetHeight(){ if (currentStyle.height != "auto") return currentStyle.height; else { var oHeight = getBoundingClientRect(); var iHeight = oHeight.bottom - oHeight.top; return iHeight; }}//+----------------------------------------------------------------------------//// Function: GetWidth//// Description: This function helps set the width of the tooltip, either// by grabbing the explicit value set on the page or by using// the getBoundingClientRect() method.//// Arguments: none//// Returns: currentStyle.width if currentStyle.width is not equal to// "auto" (which would likely signal it was not set by the// html page).// iWidth if currentStyle.width is equal to "auto". iWidth is// a value based on the getBoundingClientRect() method on// the tooltip object.////-----------------------------------------------------------------------------function GetWidth(){ if (currentStyle.width != "auto") return currentStyle.width; else { var oWidth = getBoundingClientRect(); var iWidth = oWidth.right - oWidth.left; return iWidth; }}//+----------------------------------------------------------------------------//// Function: DetachElement//// Description: Un-Attaches the events attached by AttachEvent(). This// function is called when the element property of the tooltip// is changed, so that the old element no longer calls the// tooltip.//// Arguments: none//// Returns: nothing
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -