PDA

Click to See Complete Forum and Search --> : Cursor


prog_tom
Apr 24th, 2002, 09:59 PM
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.

sebs
Apr 25th, 2002, 11:11 AM
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!



<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>

prog_tom
Apr 25th, 2002, 04:23 PM
it told me that document.all[].style is null or not an object.

sebs
Apr 25th, 2002, 04:43 PM
well, call your layer with the name you pass the function

in my example

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

is it ok?

mendhak
Apr 26th, 2002, 12:52 AM
For the sake of compatibility, use <DIV> and not <LAYERS> you're probably getting that error due to this and js probz (compatibility too!!)