Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Typed Tooltip Effect

This simple bit of scripting will create a dynamic typing effect for your tool tips.
The script can be
seen implemented here



var str='';
var obj='false';
var pntr='';
var cnt=0;
var textArr = new Array(5);
textArr[0] = "All your bases are belong to us!";
textArr[1] = "The answer is 42; of course.";
textArr[2] = "The end of the universe will be the result of a mis-calculation in the core.";
textArr[3] = "I don't believe its alive; but it thinks it is.";
textArr[4] = "About 10 seconds after you open it; you'll wish you hadn't";

function looptext()
{
   obj.innerHTML=str.substr(0,cnt);
   cnt++;
   if (cnt<=str.length) setTimeout('looptext()',100);
}

function typeText(lnk,lyr)
{
   str=textArr[lyr];
   pntr= 'lyr'+lyr;
   obj=document.getElementById(pntr);
   obj.style.left=(lnk.offsetLeft+30)+'px';
   obj.style.top=(lnk.offsetTop+25)+'px';
   obj.style.display='block';
   cnt=1;
   looptext();
}

function clearText(lyr)
{
   cnt=2500;
   pntr='lyr'+lyr;
   obj=document.getElementById(pntr);
   obj.style.display='none';
   obj.style.left='-50px';
   obj.style.top='-50px';
   obj.innerHTML='&nbsp;';
}


The links using the effect are done this way:

   <a href="javascript:alert('no page linked')"
      onmouseover="typeText(this,2)"
      onmouseout="clearText(2)"
      onclick="clearText(2)"> 
   This is link Three
   </a>

links for debugging javascript

// description of your code here

Loggers
my simple logger
MochiKit logger

Online interpreters
Squarefree JS shell 1.4
MochiKit JS interactive interpreter
TryIt Editor

debugging bookmarklets
view source
linked scripts list

// insert code here..

Wholinked

// description of your code here
Show the other websites linking to yours. Totally new and fully customizable, this simple cut-and-paste javascript queries the search engines for your links, then sends the results to your site's WhoLinked box for your visitors to see. Cool! http://wholinked.com
<script type="text/javascript"><!--
wholinked_text_color="99ccff";
wholinked_box_color="006699";
wholinked_hdln_color="99ccff";
wholinked_accent_color="000066";
wholinked_width="170px";
wholinked_font="Arial,Verdana,Sans-Serif";
wholinked_font_size="11px";
//--></script>
<script type="text/javascript" language="javascript"
src="http://wholinked.com/1.js"></script>


« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS