Click here to Skip to main content
Licence 
First Posted 25 Oct 2002
Views 188,793
Bookmarked 38 times

Transparent pop-up link with desciption using JavaScript and CSS

By | 28 Oct 2002 | Article
A simple way to make a transparent pop-up link with description.

Sample Image - maximum width is 600 pixels

Introduction

When I was surfing the web, I found some websites using some cool pop-up links with a description or you may call it a tooltip or titletip. I found it very interesting because of its transparency and thought may be you'll like it too, so I posted this article. Using a little JavaScript and CSS can help you do that easily.

Using CSS

In CSS, you would just add this code to the top of your page below the <head>, to make a CSS class in order to customize the look of the pop-up.

<style type="text/css">
  .transparent {
    filter:alpha(opacity=90);
    background-color:green;
    display:none;
    width:170;
    height:100;
    position:absolute;
    color: white;
    border: 1 green solid;
}
</style>

The heart of the code above, is the 3rd line: filter:alpha(opacity=90);. This line makes the popup transparent with the opacity value set to 90. You can set the opacity within 0 - 100. If you set to 0, you won't see the popup.

Using JavaScript

Add the script below right after the CSS above.

<script>
    /* this function shows the pop-up when
     user moves the mouse over the link */
    function Show()
    {
        /* get the mouse left position */
        x = event.clientX + document.body.scrollLeft;
        /* get the mouse top position  */
        y = event.clientY + document.body.scrollTop + 35;
        /* display the pop-up */
        Popup.style.display="block";
        /* set the pop-up's left */
        Popup.style.left = x;
        /* set the pop-up's top */
        Popup.style.top = y;
    }
    /* this function hides the pop-up when
     user moves the mouse out of the link */
    function Hide()
    {
        /* hide the pop-up */
        Popup.style.display="none";
    }
</script>

The code above is quite simple, there're only 2 functions, one to display the pop-up and another to hide the pop-up.

Using HTML

The last part is some HTML, as the code below, to the body of the page and get it up and running.

<body bgcolor="black" text="white">
<a href="" onMouseOut="Hide()" onMouseOver="Show()" 
  onMouseMove="Show()">Move the mouse over here</a><br>
<br>
Move your move over the link above<br>
and the pop-up appears. And the pop-up<br>
follows your mouse as long as your mouse<br>
is still over the link. 
<div id="Popup" class="transparent">
    <div style="background-color: #003366">
      <b>Title goes here</b></div>
    <div></b>Description goes here</div>
</div>
</body>

What else?

If you change a little bit in the CSS code, you'll get 2 more types of pop-up:

  1. Change the line filter:glow(opacity=90); to filter:progid:DXImageTransform:Microsoft.Glow(color=yellow,strength=5); and you'll get this kind of pop-up:

    Sample Image - maximum width is 600 pixels

  2. Or change the line filter:glow(opacity=90); to filter:progid:DXImageTransform:Microsoft.DropShadow(color=yellow,strength=5); and you'll get a pop-up with shadow:

    Sample Image - maximum width is 600 pixels

Note that the 2 types above work only with IE5.5+. Hope this is helpful for you!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Zek3vil



Singapore Singapore

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralWhite space Pinmembernatelywills5:25 30 Apr '09  
GeneralGood PinmemberAbbas Ali Butt4:22 10 Sep '08  
GeneralDatabase record Pinmemberbidox11:09 25 Mar '08  
GeneralMultiple Links Pinmemberbigleo238:42 11 Dec '07  
Questioncan you use this more than once? PinsussAnonymous23:09 30 Nov '03  
AnswerRe: can you use this more than once? Pinmemberguga202:26 8 Mar '07  
<script>
      /* this function shows the pop-up when
      user moves the mouse over the link */
      function Show(strObjectName)
      {
            var objDiv = document.getElementByID(strObjectName);
 
            /* get the mouse left position */
            x = event.clientX + document.body.scrollLeft;
            /* get the mouse top position   */
            y = event.clientY + document.body.scrollTop + 35;
            /* display the pop-up */
            objDiv.style.display="block";
            /* set the pop-up's left */
            objDiv.style.left = x;
            /* set the pop-up's top */
            objDiv.style.top = y;
      }
      /* this function hides the pop-up when
      user moves the mouse out of the link */
      function Hide(strObjectName)
      {
            /* hide the pop-up */
            var objDiv = document.getElementByID(strObjectName);
 
            objDiv.style.display="none";
      }
</script>
 
<body bgcolor="black" text="white">
<a href="" onMouseOut="Hide('Popup')" onMouseOver="Show('Popup')"
   onMouseMove="Show('Popup')">Move the mouse over here</a><br>
<br>
Move your move over the link above<br>
and the pop-up appears. And the pop-up<br>
follows your mouse as long as your mouse<br>
is still over the link.
<div id="Popup" class="transparent">
      <div style="background-color: #003366">
         <b>Title goes here</b></div>
      <div></b>Description goes here</div>
</div>
</body>
 

Cool | :cool:
GeneralLinks Pinmemberruben10103:42 28 May '03  
GeneralRe: Links PinmemberZek3vil3:54 28 May '03  
QuestionCross-browser compatible? PinmemberMarc Merritt1:38 28 Oct '02  
AnswerRe: Cross-browser compatible? PinmemberZek3vil3:56 28 Oct '02  
GeneralRe: Cross-browser compatible? PinmemberLoneRanger21:02 29 Oct '02  
GeneralRe: Cross-browser compatible? Pinmembermax_dcosta19:36 17 Nov '02  
GeneralRe: Cross-browser compatible? PinmemberLoneRanger20:51 17 Nov '02  
GeneralRe: Cross-browser compatible? Pinmembermax_dcosta20:55 17 Nov '02  
GeneralRe: Cross-browser compatible? PinmemberLoneRanger5:39 18 Nov '02  
GeneralRe: Cross-browser compatible? PinmembertheJazzyBrain3:30 22 Aug '03  
GeneralRe: Cross-browser compatible? PinmemberMember 377522423:54 11 Jul '08  
GeneralRe: Cross-browser compatible? PinmemberKastellanos Nikos23:10 10 Feb '03  
GeneralRe: Cross-browser compatible? PinsussAnonymous11:21 9 Jul '03  
GeneralRe: Cross-browser compatible? Pinmemberworldspawn16:38 7 Sep '03  
GeneralRe: Cross-browser compatible? PinsussAnonymous18:27 9 Jun '04  
AnswerRe: Cross-browser compatible? [modified] PinmemberMember 37781609:19 3 Jul '08  
AnswerRe: Cross-browser compatible? PinmemberJakob Flygare4:42 18 Aug '08  
GeneralRe: Cross-browser compatible? PinmemberJakob Flygare4:55 18 Aug '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120529.1 | Last Updated 29 Oct 2002
Article Copyright 2002 by Zek3vil
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid