File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ < head >
2+ < style >
3+ # divtoshow {position : absolute;display : none;color : white;background-color : black}
4+ # onme {width : 150px ;height : 80px ;background-color : yellow;cursor : pointer}
5+ </ style >
6+ < script type ="text/javascript ">
7+ var divName = 'divtoshow' ; // div that is to follow the mouse (must be position:absolute)
8+ var offX = 15 ; // X offset from mouse position
9+ var offY = 15 ; // Y offset from mouse position
10+
11+ function mouseX ( evt ) { if ( ! evt ) evt = window . event ; if ( evt . pageX ) return evt . pageX ; else if ( evt . clientX ) return evt . clientX + ( document . documentElement . scrollLeft ? document . documentElement . scrollLeft : document . body . scrollLeft ) ; else return 0 ; }
12+ function mouseY ( evt ) { if ( ! evt ) evt = window . event ; if ( evt . pageY ) return evt . pageY ; else if ( evt . clientY ) return evt . clientY + ( document . documentElement . scrollTop ? document . documentElement . scrollTop : document . body . scrollTop ) ; else return 0 ; }
13+
14+ function follow ( evt ) {
15+ var obj = document . getElementById ( divName ) . style ;
16+ obj . left = ( parseInt ( mouseX ( evt ) ) + offX ) + 'px' ;
17+ obj . top = ( parseInt ( mouseY ( evt ) ) + offY ) + 'px' ;
18+ }
19+ document . onmousemove = follow ;
20+ </ script >
21+ </ head >
22+ < body >
23+ < div id ="divtoshow "> test</ div >
24+ < br > < br >
25+ < div id ='onme ' onMouseover ='document.getElementById(divName).style.display="block" ' onMouseout ='document.getElementById(divName).style.display="none" '> Mouse over this</ div >
26+ </ body >
You can’t perform that action at this time.
0 commit comments