tras fusilar un codigo "parecido" q no se parece en nada a lo k kiero me encuentro con el problema: la imagen se situa delante de cualkier enlace y no puedo hacer click en el enlace ademas del problema q se crea cuando das varios clicks seguidos. el codigo es este, no hacen falta las imagenes el efecto se ve sin ellas.
<HTML>
<span onmousedown='return false'; oncontextmenu='return false;' ondragstart='return false';>
<script>
document.onselectstart=new Function ('return false');
</script>
<HEAD>
<script language="JavaScript">
function disableselect(e)
{
return false
}
function reEnable()
{
return true
}
//if IE4+
document.onselectstart=new Function ("return false")
//if NS6
if (window.sidebar)
{
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>
<SCRIPT LANGUAGE="JavaScript1.2">
<!-- Mas trucos y scripts en http://www.javascript.com.mx -->
var ver = navigator.appVersion;
var dom = document.getElementById ? 1 : 0;
var ie5 = (ver.indexOf("MSIE 5") > -1 && dom) ? 1 : 0;
var n = (document.layers);
var ie = (document.all);
var sparksAflyin = 0;
var totalSparks = 0;
var sparksOn = 1;
var k = 0;
function initMouseEvents() {
document.onmousedown = mouseDown;
if (n) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
}
function mouseDown(e) {
if (sparksOn) {
var mousex = (n) ? e.pageX : event.x+document.body.scrollLeft;
var mousey = (n) ? e.pageY : event.y+document.body.scrollTop;
if (!sparksAflyin) {
k = Math.random() * 8;
k = Math.round(k);
eval('SHOW("sDiv'+k+'")');
for(i = 0;i <= 9; i++)
eval('moveTo('+i+',0,'+mousex+','+mousey+')');
}
}
}
function moveTo(i,j, mousex, mousey){
if (j < eval('anim_'+i+'_x.length') ){
var tempx = eval('-50+mousex');
var tempy = eval('-50+mousey');
if (ie) {
if(tempy+30 > (document.body.offsetHeight+document.body.scrollTo p))
tempy = document.body.offsetHeight+document.body.scrollTop -30;
if(tempx+30 > (document.body.offsetWidth+document.body.scrollLef t))
tempx = document.body.offsetWidth+document.body.scrollLeft -30;
eval('document.all.sDiv'+i+'.style.left = tempx;');
eval('document.all.sDiv'+i+'.style.top = tempy;');
}
if (n) {
eval('document.layers.sDiv'+i+'.left = tempx;');
eval('document.layers.sDiv'+i+'.top = tempy;');
}
j++;
// timeout: 50 = fireworks speed, larger number = slower speed
setTimeout("moveTo("+i+","+j+","+mousex+","+mousey +")",10)
}
else {
eval('HIDE("sDiv'+i+'")');
totalSparks++;
}
if (totalSparks == 10) {
sparksAflyin = 0;
totalSparks = 0;
}
}
function SHOW(divName){
if (document.all)
eval('document.all.'+divName+'.style.visibility = "visible";');
else if (document.layers)
eval('document.layers["'+divName+'"].visibility = "visible";');
}
function HIDE(divName){
if (document.all)
eval('document.all.'+divName+'.style.visibility = "hidden";');
else if (document.layers)
eval('document.layers["'+divName+'"].visibility = "hide";');
}
anim_0_x=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_0_y=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_1_x=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_1_y=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_2_x=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_2_y=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_3_x=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_3_y=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_4_x=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_4_y=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_5_x=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_5_y=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_6_x=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_6_y=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_7_x=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_7_y=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_8_x=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_8_y=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_9_x=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
anim_9_y=new Array(-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50);
// End -->
</script>
</HEAD>
<body OnLoad="initMouseEvents()">
<div id="sparks">
<div id="sDiv0" style="position:absolute; visibility: hidden;"><font face="arial black" color="blue"><img src=triste1.gif></font></div>
<div id="sDiv1" style="position:absolute; visibility: hidden;"><font face="arial black" color="yellow"><img src=triste2.gif></font></div>
<div id="sDiv2" style="position:absolute; visibility: hidden;"><font face="arial black" color="blue"><img src=triste3.gif></font></div>
<div id="sDiv3" style="position:absolute; visibility: hidden;"><font face="arial black" color="red"><img src=triste4.gif></font></div>
<div id="sDiv4" style="position:absolute; visibility: hidden;"><font face="arial black" color="orange"><img src=triste5.gif></font></div>
<div id="sDiv5" style="position:absolute; visibility: hidden;"><font face="arial black" color="blue"><img src=triste6.gif></font></div>
<div id="sDiv6" style="position:absolute; visibility: hidden;"><font face="arial black" color="green"><img src=triste7.gif></font></div>
<div id="sDiv7" style="position:absolute; visibility: hidden;"><font face="arial black" color="blue"><img src=triste8.gif></font></div>
<div id="sDiv8" style="position:absolute; visibility: hidden;"><font face="arial black" color="yellow"><img src=triste9.gif></font></div>
<div id="sDiv9" style="position:absolute; visibility: hidden;"><font face="arial black" color="blue"><img src=triste.gif></font></div>
</div>
<a href="http://www.google.es">google</a>
</BODY>
</span>
</HTML>
los 2 problemas principales de ese codigo son:
- se ejecuta tan pronto la animacion del gif que no detecta que has pulsado sobre un hipervinculo o boton, para lo que creo yo q retrasando la animacion un poco podria valer, para eso tengo el problema de estas variables:
tengo que unir dos partes que tengo.... saco las coordenadas del puntero en una funcion
function mouseMove(e)
{
var x = (document.layers)? e.pageX : event.x+document.body.scrollLeft
var y = (document.layers)? e.pageY : event.y+document.body.scrollTop
status = "x:"+x+" y:"+y
return true
}
y tengo q conseguir meter las coordenadas en otra funcion
function mouseDownn(e) {
if (sparksOn) {
var xx = 40 //aki e metido valores fijos
var yy = 40 //aki e metido valores fijos
if (!sparksAflyin) {
k = Math.random() * 8;
k = Math.round(k);
eval('SHOW("sDiv'+k+'")');
for(i = 0;i <= 9; i++)
eval('moveTo('+i+',0,'+xx+','+yy+')'); //aki las necesito
}
}
}
pero no se como tengo que hacer para poder hacer las variables x y de las coordenadas globales para utilizarlas en esta funcion.
- el otro es que si haces varios clicks el javascript se vuelve loco ya que entran varios datos mientras se estan ejecutando, y en este no se me ocurre como podria solucionarlo, ya que lo interesante seria q se pudiesen hacer varios clicks y que se estuviesen ejecutando varios gifs a la vez sin problemas.
Vaya pedazo rayada q acabo de meter sinarme ni cuenta AJJJA no se si nisikiera se me habra entendido, a ver q se os ocurre, GRACIASSS