You don't really need Javascript for this. This is achieved by giving an element a position of fixed
:
<a id="floating_link" href="whatever.html">Go Somewhere</a>
#floating_link {
position: fixed;
right: 0;
top: 400px;
display: block;
width: 50px;
height: 125px;
text-indent: -10000px;
background-image: url(/my/image.jpg);
overflow: hidden;
}
Unfortunately, IE6 doesn't support fixed
. You can get around that by using this plugin.
If you don't care about IE6, then you can just use the above. The only difference is that IE6 will treat it as an absolute element (so it won't scroll down with the page, which isn't a big deal)
Here is an example of it at work. As you can see the entire area is clickable.
Paolo Bergantino
2009-07-06 22:40:28