Forum Moderators: open

Message Too Old, No Replies

Tooltip Help

         

digitalv

3:45 pm on Mar 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to figure out how to modify this script (or find something similar with the "talk bubble" style):

[dynamicdrive.com...]

What I want to do is have tooltips like this automatically visible near specific links when a page loads, and then have a link somewhere for the user to turn "all on" or "all off". On would be the default. These would be located on top of links, not necessarily at X/Y coordinates on the page and would have nothing to do with the mouse. So maybe this isn't the best script to use, but something with that talk bubble is the look I want.

Anyone have any ideas?

rocknbil

6:07 pm on Mar 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I absolutely hate those things. :-) I'm sure your viewers will THANK YOU for providing a way to turn them off.

This should work. At the top of your script, set a global variable for the on/off state:

var toolTipsOn = 1;

Now add this to the drivetip and hideddrivetip functions:

function ddrivetip(thetext, thewidth, thecolor){

if (toolTipsOn == 0) { return; }
......

}

The return immediately at the top will do nothing if the tips are set to off but will execute if they are on (toolTipsOn=1; )

Then create the link, set of radio buttons, or whatever to toggle the value:

<a href="#" onClick="toggleTips();">Tooltips On/Off</a>

function toggleTips() {
toolTipsOn = (toolTipsOn==0)?1:0;
}

I'd probably just use a radio button and set the variable based on the button clicked so you don't have to write out anything that says whether the current state is on or off.

As long as the user stays on this page, the toggle value will stick - but what if they change pages?

What you should do then is set a cookie, and whenever a page loads first read the cookie to determine the value of toolTipsOn. Each time it's reset - reset the cookie. This way the selection they made on the last page, on or off, will be maintained on any page the value is read.