Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Beschreibungsbox mit Javascript</title>
- <script type="text/Javascript">
- var mousex = 0;
- var mousey = 0;
- function getMouseXY(e){ // works on IE6,FF,Moz,Opera7
- if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)
- if (e){
- if (e.pageX || e.pageY){ // this doesn't work on IE6!! (works on FF,Moz,Opera7)
- mousex = e.pageX;
- mousey = e.pageY;
- algor = '[e.pageX]';
- if (e.clientX || e.clientY) algor += ' [e.clientX] '
- }else if (e.clientX || e.clientY){ // works on IE6,FF,Moz,Opera7
- mousex = e.clientX + document.body.scrollLeft;
- mousey = e.clientY + document.body.scrollTop;
- algor = '[e.clientX]';
- if (e.pageX || e.pageY) algor += ' [e.pageX] '
- }
- }
- }
- function update(e){
- getMouseXY(e); // NS is passing (event), while IE is passing (null)
- }
- function showBox(id,e){
- getMouseXY(e);
- document.getElementById(id).style.display = "block";
- document.getElementById(id).style.top = mousey + "px";
- document.getElementById(id).style.left = mousex + "px";
- }
- function hideBox(id){
- document.getElementById(id).style.display = "none";
- }
- document.onmousemove = update;
- </script>
- <style type="text/css">
- body{padding:0px;margin:0px;}
- .descbox {
- display:none;
- z-index:100;
- position:absolute;
- border:1px solid black;
- background-color:#FEFF9F;
- -moz-border-radius:5px;
- }
- </style>
- </head>
- <body>
- <a href="" onMouseOver="showBox('testbox')" onTarget="showBox('testbox')" onMouseOut="hideBox('testbox')">Testlink</a>
- <div id="testbox" class="descbox" style="width:100px;">
- Dies soll eine Beschreibung zu dem Testlink sein
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement