Results 1 to 5 of 5

Thread: Cursor

  1. #1

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post Cursor

    I want this:

    Once a person onMouseOvers his cursor on one of my imgs it just automatically sets the visibility of "lyr" to visible. and the x, y of lyr follows the x,y of the cursor. so where ever the cursor moves, the lyr follows.

    Please help.

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    Here what i did for one of our client, not the best script, but it works, in IE,NN4.x and NN6

    I try quickly with opera and did'nt work, i did'nt spend the time to figure it out!

    Code:
    		<script language="javascript">
    		var curLayer='';
    		if (document.layers) document.captureEvents(Event.MOUSEMOVE);
    		document.onmousemove=mtrack;
    
    		function mtrack(e) {
    			if(curLayer!=''){
    			  if (document.layers){
    			   	document.layers[curLayer].left=e.pageX - 110;
    					document.layers[curLayer].top=e.pageY - 120;
    					document.layers[curLayer].visibility="show";
    			  }else if(document.all){ 
    					document.all[curLayer].style.posLeft=event.x - 110;
    					document.all[curLayer].style.posTop=event.y - 120;
    			  	document.all[curLayer].style.visibility = "visible";					
    				}else{ 
    					document.getElementById(curLayer).style.left=e.pageX - 110;
    					document.getElementById(curLayer).style.top=e.pageY - 120;
    			  	document.getElementById(curLayer).style.visibility = "visible";					
    				}
    			}
    		}
    		
    			function show(what){
    				curLayer=what;
    			}
    			
    			function hide(what){
    				curLayer='';
    				if (document.all) {
    					document.all[what].style.visibility = "hidden";
    					document.all[what].style.posLeft=0;
    					document.all[what].style.posTop=0;
        		}else if (document.layers) {
        			document.layers[what].visibility="hide";
    			   	document.layers[what].left=0;
    					document.layers[what].top=0;    			
        		}else if (document.getElementById) {
        			document.getElementById(what).style.visibility="hidden";
        		}
    			}
    		</script>
    here what you put on your image

    <a href="#" onMouseOver="show('cgu');" onMouseOut="hide('cgu');"><img src="../../images/companies/cgu.gif" border="0"></a>

  3. #3

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810
    it told me that document.all[].style is null or not an object.

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  4. #4
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    well, call your layer with the name you pass the function

    in my example

    <div name="cgu">
    dssadsd
    </div>

    is it ok?

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    For the sake of compatibility, use <DIV> and not <LAYERS> you're probably getting that error due to this and js probz (compatibility too!!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width