Hover over the orange box and the link to see their Tooltips.
Hover over me to see a Tooltip!
The Tooltip Control is an extension of Overlay that is analogous to popup tooltips within common operating systems. The standard tooltip interaction pattern involves a small overlay that is displayed when the mouse hovers over a context element for a specified amount of time. Tooltip is designed to be simple to implement with easily-accessed configuration options and visual styling handled entirely via CSS.
Tooltips are instantiated by script and are rendered (and hidden) automatically when the window's load
event fires; unlike other controls in the Container family, no call to render
is required with Tooltip. Tooltip introduces several specific configuration properties:
In this tutorial, we'll create two Tooltips. The first will be associated with an element with an id of ctx
, and will have its text set explicitly. The second Tooltip will be associated with a link with an id of link
, but it will retrieve its text from the link's title
attribute:
1 | YAHOO.example.container.tt1 = new YAHOO.widget.Tooltip("tt1", |
2 | { context:"ctx", |
3 | text:"My text was set using the 'text' configuration property" }); |
4 | YAHOO.example.container.tt2 = new YAHOO.widget.Tooltip("tt2", { context:"link" }); |
view plain | print | ? |
The corresponding markup for the context elements for this tutorial looks like this:
1 | <div id="ctx">Hover over me to see a Tooltip!</div> |
2 | <a id="link" href="http://www.yahoo.com/" title="Do You Yahoo?">Hover over me to see a Tooltip!</a> |
view plain | print | ? |
You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.
INFO 3270ms (+1) 10:54:10 AM:
Config
Firing Config event: context=http://www.yahoo.com/
INFO 3269ms (+0) 10:54:10 AM:
Config
Firing Config event: iframe=false
INFO 3269ms (+0) 10:54:10 AM:
Config
setProperty: xy=8,8
INFO 3269ms (+0) 10:54:10 AM:
Config
setProperty: y=8
INFO 3269ms (+0) 10:54:10 AM:
Config
setProperty: x=8
INFO 3269ms (+0) 10:54:10 AM:
Config
Firing Config event: context=[object HTMLParagraphElement]
INFO 3269ms (+0) 10:54:10 AM:
Config
Firing Config event: iframe=false
INFO 3269ms (+0) 10:54:10 AM:
Config
setProperty: xy=8,8
INFO 3269ms (+0) 10:54:10 AM:
Config
setProperty: y=8
INFO 3269ms (+22) 10:54:10 AM:
Config
setProperty: x=8
INFO 3247ms (+0) 10:54:10 AM:
Config
Firing Config event: iframe=false
INFO 3247ms (+1) 10:54:10 AM:
Config
Firing Config event: constraintoviewport=true
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: visible=false
INFO 3246ms (+0) 10:54:10 AM:
Config
setProperty: context=http://www.yahoo.com/
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: context=link
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: disabled=false
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: container=[object HTMLBodyElement]
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: hidedelay=250
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: autodismissdelay=5000
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: showdelay=200
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: preventoverlap=true
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: preventcontextoverlap=false
INFO 3246ms (+0) 10:54:10 AM:
Config
setProperty: zindex=0
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: zindex=null
INFO 3246ms (+0) 10:54:10 AM:
Config
setProperty: autofillheight=body
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: autofillheight=body
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: fixedcenter=false
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: appendtodocumentbody=false
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: monitorresize=true
INFO 3246ms (+0) 10:54:10 AM:
Config
Firing Config event: iframe=false
INFO 3246ms (+1) 10:54:10 AM:
Config
Firing Config event: constraintoviewport=true
INFO 3245ms (+0) 10:54:10 AM:
Config
Firing Config event: visible=false
INFO 3245ms (+1) 10:54:10 AM:
Config
Firing Config event: text=My text was set using the 'text' configuration property
INFO 3244ms (+0) 10:54:10 AM:
Config
setProperty: context=[object HTMLParagraphElement]
INFO 3244ms (+0) 10:54:10 AM:
Config
Firing Config event: context=ctx
INFO 3244ms (+0) 10:54:10 AM:
Config
Firing Config event: disabled=false
INFO 3244ms (+0) 10:54:10 AM:
Config
Firing Config event: container=[object HTMLBodyElement]
INFO 3244ms (+0) 10:54:10 AM:
Config
Firing Config event: hidedelay=250
INFO 3244ms (+0) 10:54:10 AM:
Config
Firing Config event: autodismissdelay=5000
INFO 3244ms (+0) 10:54:10 AM:
Config
Firing Config event: showdelay=200
INFO 3244ms (+0) 10:54:10 AM:
Config
Firing Config event: preventoverlap=true
INFO 3244ms (+0) 10:54:10 AM:
Config
Firing Config event: preventcontextoverlap=false
INFO 3244ms (+0) 10:54:10 AM:
Config
setProperty: zindex=0
INFO 3244ms (+0) 10:54:10 AM:
Config
Firing Config event: zindex=null
INFO 3244ms (+0) 10:54:10 AM:
Config
setProperty: autofillheight=body
INFO 3244ms (+0) 10:54:10 AM:
Config
Firing Config event: autofillheight=body
INFO 3244ms (+1) 10:54:10 AM:
Config
Firing Config event: fixedcenter=false
INFO 3243ms (+13) 10:54:10 AM:
Config
Firing Config event: appendtodocumentbody=false
INFO 3230ms (+65) 10:54:10 AM:
Config
Firing Config event: monitorresize=true
INFO 3165ms (+2368) 10:54:10 AM:
LogReader instance0
LogReader initialized
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, autofillheight=body, zindex=null, preventcontextoverlap=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement], disabled=false, context=link, visible=false, constraintoviewport=true, iframe=false,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: constraintoviewport=true
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, autofillheight=body, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement], disabled=false, context=link, iframe=false, visible=false,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: visible=false
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement], disabled=false, context=link, iframe=false,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: context=link
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, iframe=false, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement], disabled=false,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: disabled=false
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: disabled=false
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: disabled
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, iframe=false, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement],
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: container=[object HTMLBodyElement]
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: container=[object HTMLBodyElement]
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: container
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: text=undefined
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: text
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, iframe=false, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: hidedelay=250
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: hidedelay=250
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: hidedelay
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, iframe=false, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: autodismissdelay=5000
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: autodismissdelay=5000
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: autodismissdelay
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, iframe=false, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: showdelay=200
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: showdelay=200
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: showdelay
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, iframe=false, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: preventoverlap=true
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: preventoverlap=true
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: preventoverlap
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, iframe=false, zindex=null, preventcontextoverlap=false, constraintoviewport=false,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: preventcontextoverlap=false
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: preventcontextoverlap=false
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: preventcontextoverlap
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, constraintoviewport=false, iframe=false, zindex=null,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: iframe=false
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: iframe=false
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: iframe
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, zindex=null, constraintoviewport=false,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: constraintoviewport=false
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: constraintoviewport=false
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: constraintoviewport
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, zindex=null,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: zindex=null
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: zindex=null
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: zindex
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: autofillheight=body
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: autofillheight=body
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: autofillheight
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: height=undefined
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: height
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: width=undefined
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: width
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: fixedcenter=false
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: fixedcenter=false
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: fixedcenter
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: context=undefined
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: context
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: xy=undefined
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: xy
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: y=undefined
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: y
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: x=undefined
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: x
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: visible=true, monitorresize=true, appendtodocumentbody=false,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: appendtodocumentbody=false
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: appendtodocumentbody=false
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: appendtodocumentbody
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: visible=true, monitorresize=true,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: monitorresize=true
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: monitorresize=true
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: monitorresize
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: effect=undefined
INFO 797ms (+0) 10:54:08 AM:
Config
Added property: effect
INFO 797ms (+0) 10:54:08 AM:
Config
Config event queue: visible=true,
INFO 797ms (+0) 10:54:08 AM:
Config
queueProperty: visible=true
INFO 797ms (+0) 10:54:08 AM:
Config
setProperty: visible=true
INFO 797ms (+1) 10:54:08 AM:
Config
Added property: visible
INFO 796ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, autofillheight=body, zindex=null, preventcontextoverlap=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement], disabled=false, context=ctx, text=My text was set using the 'text' configuration property, visible=false, constraintoviewport=true, iframe=false,
INFO 796ms (+0) 10:54:08 AM:
Config
queueProperty: constraintoviewport=true
INFO 796ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, autofillheight=body, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement], disabled=false, context=ctx, iframe=false, text=My text was set using the 'text' configuration property, visible=false,
INFO 796ms (+0) 10:54:08 AM:
Config
queueProperty: visible=false
INFO 796ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement], disabled=false, context=ctx, iframe=false, text=My text was set using the 'text' configuration property,
INFO 796ms (+0) 10:54:08 AM:
Config
queueProperty: text=My text was set using the 'text' configuration property
INFO 796ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement], disabled=false, context=ctx, iframe=false,
INFO 796ms (+0) 10:54:08 AM:
Config
queueProperty: context=ctx
INFO 796ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, iframe=false, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement], disabled=false,
INFO 796ms (+0) 10:54:08 AM:
Config
queueProperty: disabled=false
INFO 796ms (+0) 10:54:08 AM:
Config
setProperty: disabled=false
INFO 796ms (+0) 10:54:08 AM:
Config
Added property: disabled
INFO 796ms (+0) 10:54:08 AM:
Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, autofillheight=body, iframe=false, zindex=null, preventcontextoverlap=false, constraintoviewport=false, preventoverlap=true, showdelay=200, autodismissdelay=5000, hidedelay=250, container=[object HTMLBodyElement],
INFO 796ms (+0) 10:54:08 AM:
Config
queueProperty: container=[object HTMLBodyElement]
INFO 796ms (+0) 10:54:08 AM:
Config
setProperty: container=[object HTMLBodyElement]
INFO 796ms (+0) 10:54:08 AM:
Config
Added property: container
INFO 796ms (+0) 10:54:08 AM:
Config
setProperty: text=undefined
INFO 796ms (+796) 10:54:08 AM:
Config
Added property: text
Note: You are viewing this example in debug mode with logging enabled. This can significantly slow performance.
Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings