O
Oscar Monteiro
the Code below captures the Mouse move event, while event isn´t defined
anywhere it still works in IE only, how can I define the event handler so it
can work with other browsers, Firefox mostly.
-------snipped code-------------
Ymouse = -50;
Xmouse = -50;
function Mouse(evnt) {
Ymouse=event.y-20;
Xmouse=event.x;
}
----------------------------------
the hole code:
<SCRIPT type="text/javascript">
Image0 = new Image();
Image0.src = "sailormoon.jpg";
Amount = 20;
Ymouse = -50;
Xmouse = -50;
Ypos = new Array();
Xpos = new Array();
Speed = new Array();
rate = new Array();
grow = new Array();
Step = new Array();
Cstep = new Array();
nsSize = new Array();
function Mouse(evnt) {
Ymouse=event.y-20;
Xmouse=event.x;
}
document.onmousemove=Mouse;
for (i = 0; i < Amount; i++) {
Ypos = Ymouse;
Xpos = Xmouse;
Speed = Math.random()*4+1;
Cstep = 0;
Step = Math.random()*0.1+0.05;
grow = 8;
nsSize = Math.random()*15+5;
rate = Math.random()*0.5+0.1;
}
document.write('<div style="position:absolute;top:0px;left:0px"><div
style="position:relative">');
for (i = 0; i < Amount; i++) {
document.write('<img id="si'+i+'" src="'+Image0.src+'"
style="position:absolute;top:0px;left:0px;filter:alpha(opacity=90)">');
}
document.write('</div></div>');
function MouseBubbles() {
var hscrll=document.body.scrollTop;
var wscrll=document.body.scrollLeft;
for (i = 0; i < Amount; i++){
sy = Speed * Math.sin(270 * Math.PI / 180);
sx = Speed * Math.cos(Cstep * 4);
Ypos += sy;
Xpos += sx;
if (Ypos < -40) {
Ypos = Ymouse;
Xpos = Xmouse;
Speed = Math.random() * 6 + 4;
grow = 8;
nsSize = Math.random() * 15 + 5;
}
document.getElementById("si"+i).style.pixelLeft = Xpos + wscrll;
document.getElementById("si"+i).style.pixelTop = Ypos + hscrll;
document.getElementById("si"+i).style.width = grow;
document.getElementById("si"+i).style.height = grow;
grow += rate;
Cstep += Step;
if (grow > 24) grow = 25;
}
setTimeout('MouseBubbles()', 10);
}
MouseBubbles();
</script>
wish you all a nice weekend , and many thank for the help
in the previous posts.
Best Regards
anywhere it still works in IE only, how can I define the event handler so it
can work with other browsers, Firefox mostly.
-------snipped code-------------
Ymouse = -50;
Xmouse = -50;
function Mouse(evnt) {
Ymouse=event.y-20;
Xmouse=event.x;
}
----------------------------------
the hole code:
<SCRIPT type="text/javascript">
Image0 = new Image();
Image0.src = "sailormoon.jpg";
Amount = 20;
Ymouse = -50;
Xmouse = -50;
Ypos = new Array();
Xpos = new Array();
Speed = new Array();
rate = new Array();
grow = new Array();
Step = new Array();
Cstep = new Array();
nsSize = new Array();
function Mouse(evnt) {
Ymouse=event.y-20;
Xmouse=event.x;
}
document.onmousemove=Mouse;
for (i = 0; i < Amount; i++) {
Ypos = Ymouse;
Xpos = Xmouse;
Speed = Math.random()*4+1;
Cstep = 0;
Step = Math.random()*0.1+0.05;
grow = 8;
nsSize = Math.random()*15+5;
rate = Math.random()*0.5+0.1;
}
document.write('<div style="position:absolute;top:0px;left:0px"><div
style="position:relative">');
for (i = 0; i < Amount; i++) {
document.write('<img id="si'+i+'" src="'+Image0.src+'"
style="position:absolute;top:0px;left:0px;filter:alpha(opacity=90)">');
}
document.write('</div></div>');
function MouseBubbles() {
var hscrll=document.body.scrollTop;
var wscrll=document.body.scrollLeft;
for (i = 0; i < Amount; i++){
sy = Speed * Math.sin(270 * Math.PI / 180);
sx = Speed * Math.cos(Cstep * 4);
Ypos += sy;
Xpos += sx;
if (Ypos < -40) {
Ypos = Ymouse;
Xpos = Xmouse;
Speed = Math.random() * 6 + 4;
grow = 8;
nsSize = Math.random() * 15 + 5;
}
document.getElementById("si"+i).style.pixelLeft = Xpos + wscrll;
document.getElementById("si"+i).style.pixelTop = Ypos + hscrll;
document.getElementById("si"+i).style.width = grow;
document.getElementById("si"+i).style.height = grow;
grow += rate;
Cstep += Step;
if (grow > 24) grow = 25;
}
setTimeout('MouseBubbles()', 10);
}
MouseBubbles();
</script>
wish you all a nice weekend , and many thank for the help
in the previous posts.
Best Regards