Nov 21, 2009

Creating Tooltips - DHTML, HTML, CSS, Javascript...

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > How-To's and Tutorials > Websites and Web Designing

Creating Tooltips - DHTML, HTML, CSS, Javascript...

GM-University
Here is a little tutorial to make those small yellow-background boxes (tootltips) that pop-up for some links that describe them when you hover the mouse over them, it uses DHTML, CSS, HTML, and Javascript, so it gives us a much more wide range than my previous tutorials that just where on HTML.
OK, so here we go...

Put this right under <body>
CODE
<div id="dhtmltooltip"></div>
<script type="text/javascript">

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

</script>


Put this with your CSS <style> tag, or .css file.
CODE
#dhtmltooltip {
position: absolute;
width: 150px;
border: 1px solid #C1C1C1;
padding: 2px;
background-color: #EFEFEF;
color: #000000;
visibility: hidden;
z-index: 100;
filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);
}


And put this in your link
CODE
onMouseover="ddrivetip('Your tooltip text','black', 300)";
onMouseout="hideddrivetip()"

A link example would be
CODE
<a href="http://www.trap17.com/forums/saint-michaels-html-tips-tricks-4-t24328.html"onMouseover="ddrivetip('Your text here','red', 300)";
onMouseout="hideddrivetip()">Text Here</a>

 

 

 


Comment/Reply (w/o sign-up)

AzNxSuperNova
I personally tried this tutorial and it was very straight forward. I was able to get the results and find that it can easily be customized to suit your needs through the CSS <style> tag. I also would like to point out that when I opened it in Internet Explorer, it was initially blocked with Internet Explorer saying that it was restricting the file from showing active content that could access your computer. However, I'm not sure if other browsers block it. Either way, it was a great tutorial and very helpful.

Comment/Reply (w/o sign-up)

GM-University
QUOTE (AzNxSuperNova @ Jul 15 2005, 11:56 PM)
I personally tried this tutorial and it was very straight forward. I was able to get the results and find that it can easily be customized to suit your needs through the CSS <style> tag. I also would like to point out that when I opened it in Internet Explorer, it was initially blocked with Internet Explorer saying that it was restricting the file from showing active content that could access your computer. However, I'm not sure if other browsers block it. Either way, it was a great tutorial and very helpful.
*

Yeah, Internet Explorer does that with Javascript for me too, so that is why I only use FireFox now, thanks for the feedbakc. smile.gif

 

 

 


Comment/Reply (w/o sign-up)

Neverseen
very nice tutorial smile.gif A lot of code ! hehe tongue.gif quite usefull and easy to understand wink.gif thanks

Comment/Reply (w/o sign-up)

Illudar
Nice tutorial. I like it a lok, easy to understand and helpful!

Comment/Reply (w/o sign-up)

abhiram
Great tutorial. I'm going to use this in my site. Thanks a lot.

Comment/Reply (w/o sign-up)

FeedBacker
thanks
Creating Tooltips

This is really nice,

I have tried this for the image but its doesn't work?

-reply by sudhir

Comment/Reply (w/o sign-up)

naro2212
WoW i thought that was only possible for ads well TY dose it work with images and can you change the color of them

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : creating, tooltips, dhtml, html, css, javascript

  1. 4 Html Based Website Tips
    (4)
  2. Coding Html Properly In The New Age
    (15)
    In all your html there are things you want to follow. Always use lowercase for your HTML Tags
    Don't use upper case. Upper case is bad (this can be hard to do if your like me and tend to
    write and then for closing:P). CODE Types of Staff Administrators: SilverFox,
    Danmidas Above: Bad Code Below: Good Code CODE Types of Staff Administrators:
    SilverFox, Danmidas Use Self-Closing Tags In html certain tags (ex. img, br, hr) didn't
    need closing tags. However its best to write them with something called self-closing tags. ....
  3. A Tutorial For Html Color Codes
    (7)
    HTML Coloring System - RGB Values RGB which stands for Red, Green, Blue. Each can have a value from
    0 (none of that color) to 255 (fully that color). The format for RGB is - rgb(RED, GREEN, BLUE),
    just like the name implies. Below is an example of RGB in use. Red, Green, and Blue Values:
    bgcolor="rgb(255,255,255)" White bgcolor="rgb(255,0,0)" Red bgcolor="rgb(0,255,0)" Green
    bgcolor="rgb(0,0,255)" Blue HTML Color Code - Breaking the Code The following table shows how
    letters are incorporated into the hexadecimal essentially extending the numbers system to 16 values....
  4. Integrating Html And Css
    (9)
    QUOTE(the_aggie10 @ Trap17.com) Ok. Well i am writing this as a series of tutorials i will be
    doing on this subject, so enjoy. I hope this helps. Introduction
    to HTML and CSS HTML and CSS are to work together. HTML is what puts the characters
    on the page, while CSS is what makes everything look outreageous! For instance, I would use HTML if
    i wanted to put "Trap17 is the poop!" onto my page, although if i wanted to make it look nice like
    this by adding a font, and maybe some color, then I would use CSS. Learn the ....
  5. Creating Your Own Simple But Effective Site
    To be resumed soon (26)
    Creating your own UKISS site from beginning to end Contents So that you know
    what is happening and when I’ve compiled this contents section. It will also help you got to
    the parts that you need without scrawling through everything. Introduction Design Step 1
    – Starting Fireworks and creating your canvas Step 2 – Making a base on which to work
    on Step 3 – Head’s up; start with the logo Step 4 – Finding your way;
    creating a menu Step 5 – Eyes to the centre; work on the main column Step 6....
  6. {} Changing Font Color / Size {}
    Basic HTML for beginners (14)
    Changing the Size of your Font: - So you've got basic text on your website but its JUST
    not what you want. Why not change the size of your font. It can both attract and reject viewers so
    becareful how you use it. This tutorial will show you how to do that in very easy, basic steps!
    Getting Started.. - Changing the size of your font is quite easy. It requires TWO tags. These two
    tags require the Brackets and ending brackets (tags) . If you do not put the ending tag, the font
    size will effect your entire website, changing it to that font size. Below is wha....
  7. {} Html'ing & Basic Codes {}
    Basic coding HTML for beginners! (0)
    ** I was looking through the tutorials page and I saw one tutorial on beginning HTML, I thought I
    would expand a little on it and show ya some basic codes you can use for your website if your
    beginning HTML! ** Beginning HTML HTML isnt all that hard. Once you get the hang of it, its
    quite a breeze, but sense your starting out new and would like some basic help on how to do simple
    things regarding HTML heres a little help for you! First off, lets start out with what HTML means
    and what you need to write it. * HTML - H ypertext M arkup L anguage which is a....
  8. Creating A Simple But Effective Website
    Part 1 - Design (10)
    WARNING: This is a VERY image heavy tutorial and will take time to complete Topic closed
    until I can find the time to complete it, and I am getting mad with the large scale plagrism of
    other articles. Also, the images will no longer work, as I have changed domain name and also
    removed the images to make space. Creating a basic but effective website For beginners
    Introduction: Ok, so maybe you want to make a website that is “worthy” of the web. That is to say,
    you have made small taster sites before in FrontPage or something basic like it. And realised t....
  9. Html Meta Tags Tutorial
    -What it is/does; how to utilize it- (21)
    So, you've got your beginning page started, your homepage is defined, neat, and it looks like
    everyone will love it - STOP. Do you really think your site will be even accidently view by anyone,
    even if you do have a bought domain?! Don't kid yourself; the fact of the matter is, you're
    just one infantesimle speck in the universe of much greater websites than yours. Don't worry,
    though - I got your back. Here, I'm gonna explain what meta tags are, and what they're used
    for. I'm also going to show how to utilize them for your site, to increa....
  10. Starting Your Website With Html
    To build a website, you need to know HOW (7)
    I was reading through the tutorials, and it seems throughout the tutorials, no one has ever really
    taught how to build a beginner's page using HTML. Not that it's anyone's fault, but
    if someone is unsure of how to begin and end a page with HTML, then they will not be able to make a
    page. So, I figured I'd lend a hand... -------------------------------------------- To begin
    your first webpage using HTML, you will need these tags* (in this order): CODE YOUR TITLE
    FOR YOUR PAGE THIS IS WHERE YOUR MAIN TEXT GOES To explain: The ....
  11. Upgrading Your Site!
    Move from HTML 4.01 to XHTML 1.0 (0)
    I planned to post 3 different parts because of the length, but so there's no confusion, I'll
    just make one big tutorial all together /cool.gif" style="vertical-align:middle" emoid="B)"
    border="0" alt="cool.gif" /> . ====================================== (A note to the moderators:
    Alright, I've got this down now, so please delete all of my other posts besides this one, and
    any posting credits as well; thanks!) ====================================== Now the tutorial:
    Concerning those in the webmaster biz... If you are an aspiring experienced webmaster, the....
  12. Creating Rollover Images With Css
    Eliminate the need for Javascript (12)
    I have seen it reported that 10% of Internet users have Javascript disabled. Whether for security
    concerns or to curtail annoyances like pop-up windows, it seriously limits your ability, as a web
    designer, to mold your website into something creative and novel. This is where CSS rollovers come
    in. You know that effect you get when you roll the cursor over an image, and then the image changes?
    Traditionally, that effect has been accomplished by using Javascript to swap out images. I present
    here my own index page which has been made only with CSS and html. If you are u....
  13. Three Html/ Css/ Javascript Tutorials
    (6)
    Here are some tutorials that always get great results when I post them. Lesson 1 HTML means Hyper
    Text Markup Language. HTML is a very common language used for many websites, is the base for more
    complicated and powerful langauges like php, HTML can seem hard, but you will find it is one of the
    easiest langauges one can learn. The core of HTML is the tag, a tage is just a set of two
    arrows-like brackets created by hitting Shift and the comma key, or Shift and the period key. They
    look like this... HTML HTML > Tags start a change in the way a webpage ....
  14. Creating A Css Rollover Menu (with Table Cells)
    for those bandwidthed challenged (9)
    Ive found this code very usefull when it comes to clients who cant afford Flash (and I hate
    JavaScript rollovers as they only work half the time and when you hold the mouse over the button for
    5 seconds) When your done here you should be able to create a menu that looks like the following:
    click here to see what it looks like Step 1: setting up the framework Get the framework in
    there for the script to work , I generally link to my stylesheets externally so I will show you how.
    Now open a simple text editor such as Notepad. set up your page with the following bas....
  15. Creating A Webpage Using Photoshop
    (4)
    I've read that this can be done with greater ease by using Ready Image, but since I'm more
    familiar with PS, I shall use PS as the guide. This guide does make a few assumptions :: 1) You
    already knew how to use Photoshop. 2) You already knew how to write HTML codes 3) You knew both of
    the above but did not ralise that it can be done .. Thus, I shall not touch on those 2 topics, as
    books a thousand pages thick have been written on them. So, I would wanna waste my time and yours
    and all the disksapce that could be used to host some useful stuff. 01:. Open the....
  16. This Page Was Last Modified On.....
    useful javascript... check it out (4)
    This javascript will show when the page was last modified. You can replace "This page was last
    updated on" with your own message.. CODE  function initArray() {        this.length =
    initArray.arguments.length      for (var i = 0; i      this = initArray.arguments   }   var
    DOWArray = new initArray("Sunday","Monday","Tuesday","Wednesday",                              
     "Thursday","Friday","Saturday");   var MOYArray = new
    initArray("January","February","March","April",                              
     "May","June","July","August","September",         ....
  17. Uploading A Html Format Page
    (0)
  18. Creating A Color Combination
    Guide to color combinations (18)
    Ever been to a website that is barely readable because of the bad color design? Well here's some
    tips to make sure that you don't fall into the same trap. * Black text on a white background,
    while not exciting, is the most practical color combination. * Try and not use more then four
    colors on your website, too many can be disorientating for the user. * Find out what each color
    represents to the users mind. For example green represents wealth while red represents daring. *
    Don't use yellow for web page backgrounds. * Take a look at Visibone or get a....
  19. Creating A Roll-over Effect With Text
    Save time and bandwidth-simple scripting (11)
    This short, but consise tutorial presents how to create a dynamic navigation bar using simple
    scripting verses using an image roll-over script. Using text instead of images offers 3 benefits
    while sacrificing only a little in design. The end resault is a navigation bar that looks great,
    dosen't bog the server down with images, loads fast, and is search engine friendly. In addition,
    you save time by not having to design two images for every link required. Using simple combination
    of Html, CSS, and Javascript we are able to create links in which both the color of th....
  20. Add Favicon To Your Site
    Creating, Converting to icon, Setup (39)
    Have you ever wondered how to get those icons displayed in your address bar for your own site? If
    you do not know what I mean, you could possibly have a browser that does not support favicon.ico or
    you just have not noticed. If you visit Google they should have a favicon in their address bar,
    if it's not displaying just goto this place to get the idea of what it would look like, but in
    your address bar, it should show just before the http part but sometimes it does not show so what I
    want to do is show you how you can force it to be shown on browsers that sup....

    1. Looking for creating, tooltips, dhtml, html, css, javascript

See Also,

*SIMILAR VIDEOS*
Searching Video's for creating, tooltips, dhtml, html, css, javascript
advertisement



Creating Tooltips - DHTML, HTML, CSS, Javascript...

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com