Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.74 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Beschreibungsbox mit Javascript</title>
  4.         <script type="text/Javascript">
  5.             var mousex = 0;
  6.             var mousey = 0;
  7.            
  8.             function getMouseXY(e){ // works on IE6,FF,Moz,Opera7
  9.             if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)
  10.                
  11.                 if (e){
  12.                     if (e.pageX || e.pageY){ // this doesn't work on IE6!! (works on FF,Moz,Opera7)
  13.                         mousex = e.pageX;
  14.                         mousey = e.pageY;
  15.                         algor = '[e.pageX]';
  16.                         if (e.clientX || e.clientY) algor += ' [e.clientX] '
  17.                     }else if (e.clientX || e.clientY){ // works on IE6,FF,Moz,Opera7
  18.                         mousex = e.clientX + document.body.scrollLeft;
  19.                         mousey = e.clientY + document.body.scrollTop;
  20.                         algor = '[e.clientX]';
  21.                         if (e.pageX || e.pageY) algor += ' [e.pageX] '
  22.                     }  
  23.                 }
  24.             }
  25.            
  26.             function update(e){
  27.                 getMouseXY(e); // NS is passing (event), while IE is passing (null)
  28.             }
  29.  
  30.             function showBox(id,e){
  31.                 getMouseXY(e);
  32.                 document.getElementById(id).style.display = "block";
  33.                 document.getElementById(id).style.top = mousey + "px";
  34.                 document.getElementById(id).style.left = mousex + "px";
  35.             }
  36.            
  37.             function hideBox(id){
  38.                 document.getElementById(id).style.display = "none";
  39.             }
  40.            
  41.             document.onmousemove = update;
  42.         </script>
  43.         <style type="text/css">
  44.             body{padding:0px;margin:0px;}
  45.            
  46.             .descbox    {
  47.                 display:none;
  48.                 z-index:100;
  49.                 position:absolute;
  50.                 border:1px solid black;
  51.                 background-color:#FEFF9F;
  52.                 -moz-border-radius:5px;
  53.             }
  54.         </style>
  55.     </head>
  56.     <body>
  57.         <a href="" onMouseOver="showBox('testbox')" onTarget="showBox('testbox')" onMouseOut="hideBox('testbox')">Testlink</a>
  58.         <div id="testbox" class="descbox" style="width:100px;">
  59.             Dies soll eine Beschreibung zu dem Testlink sein
  60.         </div>
  61.     </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement