Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 20th, 2005, 09:22 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to make Tool Tips when onmouseover

I would imagine it is possible to have tool tips with Javascript when onmouseover objects on a page. How would you do this?

 
Old January 20th, 2005, 09:34 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

No need for JavaScript, use "title" attribute of element.

http://msdn.microsoft.com/library/de...ence_entry.asp

--

Joe (Microsoft MVP - XML)
 
Old January 30th, 2005, 02:40 PM
Authorized User
 
Join Date: Jan 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is as simple as this

<span title=
Quote:
quote:your tool tip here
>whatever you want to be tool tipped goes in here</span>

 
Old January 30th, 2005, 02:42 PM
Authorized User
 
Join Date: Jan 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oops!..i guess i made a jumble of the "FORUM CODE" ... so here goes the code for the tool tip again...

<span title="your tool tip here">whatever you want to be tool tipped goes in here</span>

 
Old February 2nd, 2005, 01:18 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Yes they are right. But if you still want to go with Javascript way .. check this article ... http://tech.irt.org/articles/js202/index.htm

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old February 2nd, 2005, 08:53 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

This is better for what you want to do:

// Copy into head

<SCRIPT type=text/javascript><!--

var docTips = new TipObj('docTips');
with (docTips)
{


 template = '<table bgcolor="#003366" cellpadding="1" cellspacing="0" width="200" border="0">' +
  '<tr><td><table bgcolor="#6699CC" cellpadding="3" cellspacing="0" width="100%" border="0">' +
  '<tr><td class="tipClass">%3%</td></tr></table></td></tr></table>';


 tips.mysite = new Array(-75, 15, 150, 'Visit this for updates, help and more info');
 tips.welcome = new Array(5, 5, 100, 'Hope you like it...');
 tips.useful = new Array(5, 5, 150, 'This can add important context information to any link...');
 // This next tip uses a formula to position the tip 110 pixels from the right edge of the screen.
 tips.formulae = new Array(5, 50, 150,
  'The Grand Total for the entire journey including basic fare price, taxes and booking fees');
 tips.formulae2 = new Array(-550, 10, 150,
  'The details of your entire journey including your departure/arrival dates and times for all flights, departure airports (with XXX codes), arrival airports (with XXX codes), any stops (if applicable), the class of the passengers seat and the cabin on-board');
 tips.formulae3 = new Array(-550, 10, 150,
  'The Fare price broken down to detail out all the Fare Basis, Fare Rules, Fare Price before Tax, Fare Price after Tax, the number of passengers and booking fees (if applicable)');
 tips.formulae4 = new Array(-550, 10, 150,
  'The Fare markups for Adult Fares, Child Fares and Infant Fares');
 tips.formulae5 = new Array(-20, 70, 150,
  'Enter Title (e.g. Mr, Mrs, Miss, Ms etc)');
 tips.formulae6 = new Array(-20, 70, 150,
  'Enter Passengers forename');
 tips.formulae7 = new Array(-20, 70, 150,
  'Enter Passengers surname');
 tips.formulae8 = new Array(-20, 70, 150,
  'Select the requested seat on-board');
 tips.formulae9 = new Array(-20, 70, 150,
  'Select required in-flight meal (if applicable)');
 tips.formulae10 = new Array(-20, 70, 150,
  'Enter any special requests');

 tips.format = new Array(5, 5, 150, 'That means <i>italics</i>...<br />...etc');



}

var staticTip = new TipObj('staticTip');
with (staticTip)
{
 // I'm using tables here for legacy NS4 support, but feel free to use styled DIVs.
 template = '<table bgcolor="#000000" cellpadding="0" cellspacing="0" width="200" border="0">' +
  '<tr><td><table cellpadding="3" cellspacing="1" width="100%" border="0">' +
  '<tr><td bgcolor="#336666" align="center" height="18" class="tipClass">%3%</td></tr>' +
  '<tr><td bgcolor="#009999" align="center" height="*" class="tipClass">%4%</td></tr>' +
  '</table></td></tr></table>';

 // HIERARCHIAL TIPS: To call one tip object from within another tip object, make sure you
 // pass the a reference to the current object as the second parameter to the show() function.
 tips.links = new Array(5, 5, 100, 'Extra Links',
  '- <a href="javascript:alert(\'Useful indeed...\')">Section 1</a> -<br />' +
  '- <a href="#" name="nest1trig" onmouseover="nestTip.show(\'nest1\', staticTip)" ' +
   'onmouseout="nestTip.hide()">NESTED TIP 1 &gt;</a> -<br />' +
  '- <a href="#" name="nest2trig" onmouseover="nestTip.show(\'nest2\', staticTip)" ' +
   'onmouseout="nestTip.hide()">NESTED TIP 2 &gt;</a> -<br />');

 tipStick = 0;
}

// Here's the other tip object called by the one above, for hierarchial tips.
var nestTip = new TipObj('nestTip');
with (nestTip)
{
 template = '<table bgcolor="#000000" cellpadding="1" cellspacing="0" width="%2%" border="0">' +
  '<tr><td><table bgcolor="#009999" cellpadding="3" cellspacing="0" width="100%" border="0">' +
  '<tr><td class="tipClass">%3%</td></tr></table></td></tr></table>';

 tips.nest1 = new Array(10, 0, 90,
  '<a href="javascript:alert(\'A regular popup menu...\')">Relative Position</a>');

 // This tip is positioned via formulae based on its parent tip's position...
 tips.nest2 = new Array('staticTip.xPos + 95', 'staticTip.yPos + 50', 80,
  '<a href="javascript:alert(\'Nested tip 2\')">Absolutely positioned static tip...</a>');

 tipStick = 0;
}

var stickyTip = new TipObj('stickyTip');
with (stickyTip)
{
 template = '<table bgcolor="#000000" cellpadding="1" cellspacing="0" width="%2%" border="0">' +
  '<tr><td><table bgcolor="#339966" cellpadding="4" cellspacing="0" width="100%" border="0">' +
  '<tr><td align="center" class="tipClass">%3%</td></tr></table></td></tr></table>';

 tips.floating = new Array(5, 5, 100, 'Floating tips can have extra effect!');

 tipStick = 0.2;
}



//--></SCRIPT>

---------------------------------------------------------

// Copy below opening <body> tag

<DIV id=docTipsLayer
style="Z-INDEX: 10000; LEFT: 0px; VISIBILITY: hidden; WIDTH: 10px; POSITION: absolute; TOP: 0px"></DIV>
<DIV id=staticTipLayer
style="Z-INDEX: 10000; LEFT: 0px; VISIBILITY: hidden; WIDTH: 10px; POSITION: absolute; TOP: 0px"></DIV>
<DIV id=nestTipLayer
style="Z-INDEX: 10000; LEFT: 0px; VISIBILITY: hidden; WIDTH: 10px; POSITION: absolute; TOP: 0px"></DIV>
<DIV id=stickyTipLayer
style="Z-INDEX: 10000; LEFT: 0px; VISIBILITY: hidden; WIDTH: 10px; POSITION: absolute; TOP: 0px"></DIV>

__________________________________________________ ________

// Copy to mouseover

onmouseover="docTips.show('formulae2');style.curso r='hand'" onmouseout="docTips.hide()"






Similar Threads
Thread Thread Starter Forum Replies Last Post
Tips for organizing Team Projects? vcohen BOOK: Professional Team Foundation Server ISBN: 0-471-91930-6 0 April 9th, 2007 05:10 PM
how to add tool tips for drop down list ? wlin ASP.NET 2.0 Basics 0 November 20th, 2006 04:12 PM
hints and tips needed Vano2005 C# 6 July 13th, 2005 11:42 AM
Tool Tips in C# DAK BOOK: Professional C#, 2nd and 3rd Editions 0 January 8th, 2004 12:35 AM
How to add tool tips to button control Kevin M VB.NET 2002/2003 Basics 3 October 27th, 2003 01:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.