Custom tooltip style : Popup ToolTip « Ajax Layer « JavaScript DHTML






Custom tooltip style


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>YAHOO.widget.Tooltip</title>

<script type="text/javascript" src="./build/yahoo/yahoo.js" ></script>
<script type="text/javascript" src="./build/event/event.js" ></script>
<script type="text/javascript" src="./build/dom/dom.js" ></script>

<link rel="stylesheet" type="text/css" href="./build/fonts/fonts.css" />
<link rel="stylesheet" type="text/css" href="./examples/container/css/example.css" />

<link rel="stylesheet" type="text/css" href="./build/container/assets/container.css" />
<script type="text/javascript" src="./build/container/container.js"></script>

<script language="javascript">

  var tooltip1;
  var tooltip2;
  var tooltip3;

  function init() {

    tooltip2 = new YAHOO.widget.Tooltip("tt2", { context:"link" } );
    tooltip3 = new YAHOO.widget.Tooltip("tt3", { context:"img", showdelay: 1000 });
  }

  YAHOO.util.Event.addListener(window, "load", init);
</script>
</head>
<body>
  <div class="box" id="bodyMain">
    <div class="hd">
      <h1>Tooltip Example</h1>
    </div>
    <div class="bd">
      <p>The creation of a Tooltip is very straight-forward. To instantiate a Tooltip, the code looks like this:</p>
      <code>tooltip1 = new YAHOO.widget.Tooltip("tt1", { context:"btn1", text:"I'm a button. You can click me!" } );</code>
      <p>Tooltips are generally always created dynamically, and never need to be marked up in advance. The first argument is the DOM id that you want to associate with the Tooltip. The second argument is the user configuration object literal used for configuring the Tooltip. If no text is specified, the Tooltip will attempt to use the object's title attribute to set the text.</p>
      <p>The first example, tooltip1, is included in an inline script tag to demonstrate that Tooltip classes can be included inline during document rendering.</p>
      <p>By default, are shown after 200ms, displayed for 5 seconds and dismissed, or hidden 250ms after moving the mouse away from the context element. You can configure these timings, as shown in the code for tooltip3 (the one associated with the image), where we cause the Tooltip to display after 1 second, instead of the default:</p>
      <code>tooltip3 = new YAHOO.widget.Tooltip("tt3", { context:"img", showdelay: 1000 });</code>
      <p style="margin-top:25px;padding-top:25px;border-top:1px dotted black"><button id="btn1">Hover over me</button></p>
      <script>tooltip1 = new YAHOO.widget.Tooltip("tt1", { container:"bodyMain", context:"btn1", text:"I'm a button. You can click me!"} ); // This code is placed inline in a script tag to show that tooltips can be instantiated inline as well.</script>
      <p><a id="link" href="http://www.yahoo.com" title="I'm a link! I go to another page!" alt="">Hover over me too!</a></p>
      <p><img id="img" src="http://us.i1.yimg.com/us.yimg.com/i/nt/ic/ut/alt3/close12_1.gif" title="I'm an image and this is my title text!"/></p>

    </div>
  </div>


</body>
</html>

           
       








yui.zip( 3,714 k)

Related examples in the same category

1.Tooltip with caption
2.With caption 2
3.Plain popup
4.With simple caption
5.STICKY tooltips
6.Insert HTML code into the tooltip text
7.overLIB: other side of the mouse
8.overLIB: snapping to a grid
9.overLIB: fixating the position
10.overLIB: all the features
11.overLIB - link
12.[DOM Tooltip] Example 1: Native Tooltips
13.[DOM Tooltip] Example 2: Basic Features
14.[DOM Tooltip] Example 3: Styled Tooltips (overlib style)
15.[DOM Tooltip] Example 3: Styled Tooltips (overlib style with caption)
16.[DOM Tooltip] Example 3: Styled Tooltips (nicetitles style)
17.[DOM Tooltip] Example 4: Behavior Options (Click to stick)
18.[DOM Tooltip] Example 4: Behavior Options (Custom close link)
19.[DOM Tooltip] Example 4: Behavior Options for a text field
20.[DOM Tooltip] Example 5: Advanced Features (Snap to grid)
21.[DOM Tooltip] Example 5: Advanced Features (Tooltip fading in)
22.[DOM Tooltip] Example 5: Advanced Features (Lazy trailing)
23.[DOM Tooltip] Example 5: Advanced Features (One tooltip only)
24.[DOM Tooltip] Example 6: XHTML Content(display an image inside a window)
25.[DOM Tooltip] Example 6: XHTML Content with image
26.[DOM Tooltip] Example 6: XHTML Content(Open an Inline window)
27.[DOM Tooltip] Example 6: XHTML Content
28.[DOM Tooltip] Example 7: Object Detection (DOM Tooltip can hunt down and hide these elements that cannot be overlapped)
29.[DOM Tooltip] Example 8: Custom Context Menu
30.[DOM Tooltip] Example 10: Onload PopIn
31.[DOM Tooltip] Example 13: Nested Tooltips
32.[DOM Tooltip] Example 14: Positioning
33.[DOM Tooltip] Example 9: Auto-Generated Tips (black background)
34.[DOM Tooltip] Example 9: Auto-Generated Tips with URL
35.[DOM Tooltip] Example 9: Auto-Generated Tips(a long paragraph)
36.TextField ToolTip