Muy buenas
Estoy utilizando la siguiente función en una web para hacer que el puntero vaya dejando una imagen como estela
Código:
<script language="JavaScript1.2">
<!--
var largo = 12 // Largo de la estela (8 por defecto)
var ruta = "/templates/247portal-b-blue2/ball.gif" // Ubicación de la imagen
var isIE = false,isNav = false,range = "all.",style = ".style",i,d = 0
var topPix = ".pixelTop",leftPix = ".pixelLeft",imagenes,restoimg
if (document.layers) {
isNav = true,range = "layers.",style = "",topPix = ".top",leftPix = ".left"
} else if (document.all) {
isIE = true
}
function empezar() {
imagenes = new Array()
for (i = 0; i < parseInt(largo); i++) {
imagenes[i] = new Image()
imagenes[i].src = ruta
}
restoimg = new Array()
for (i = 0; i < imagenes.length*3; i++) {
restoimg[i] = 0
}
for (i = 0; i < imagenes.length; i++) {
(isIE) ? document.write('<div id="obj' + i + '" style="position: absolute; z-Index: 100; height: 0; width: 0"><img src="' + imagenes[i].src + '"></div>') : document.write('<layer name="obj' + i + '" width="0" height="0" z-index="100"><img src="' + imagenes[i].src + '"></layer>')
}
estela()
}
function estela() {
for (i = 0; i < imagenes.length; i++) {
eval("document." + range + "obj" + i + style + topPix + "=" + restoimg[d])
eval("document." + range + "obj" + i + style + leftPix + "=" + restoimg[d+1])
d = d+2
}
for (i = restoimg.length; i >= 2; i--) {
restoimg[i] = restoimg[i-2]
}
d = 0
var timer = setTimeout("estela()",10)
}
function procesar(e) {
if (isIE) { // para IE
restoimg[0] = window.event.y+document.body.scrollTop+10
restoimg[1] = window.event.x+document.body.scrollLeft+10
} else { // para Netscape Navigator
restoimg[0] = e.pageY+12
restoimg[1] = e.pageX+12
}
}
if (isNav) {
document.captureEvents(Event.MOUSEMOVE)
}
if (isIE || isNav) {
empezar()
document.onmousemove = procesar
}
//-->
</script>
Funciona sin problemas, pero intento buscar una manera con la que activar/desactivar esa función, mediante un enlace/interruptor en la web. Por ejemplo...
Código:
<script>
var n=0
function interruptor(){
n++;
if(n%2==0){return "1";} else return "0";
}
</script>
Con una función que cambia el valor del "interruptor"
Código:
<a href=# onclick="alert(interruptor()">Interruptor</a>
Y el enlace que la llama...
Pero de ahi no paso... ¿Alguien sabe como hacerlo?