Back to top

Autore Topic: Effetto javascript scia che segue il mouse  (Letto 3902 volte)

Offline dinox

  • Esploratore
  • **
  • Post: 92
    • Mostra profilo
Effetto javascript scia che segue il mouse
« il: 05 Set 2009, 20:01:17 »
Allora ho inserito dell'index.php del template il seguente codice:

Codice: [Seleziona]
<?php
   $filename 
'mouse.js';
   
$path '/media/system/js/';    // aggiungere il percorso esatto se è differente da 'media/system/js/'
    
JHTML::script($filename$path,true);
?>

ma lo script non funziona o meglio esce l'immagine che dovrebbe seguire il mouse ma rimane fissa in alto a sinistra, il codice javascript è questo:

Codice: [Seleziona]
<!-- Begin
// Cross browser cursor trailer script - By Brian Caputo (bcaputo@icdc.com)

B=document.all;
C=document.layers;
T1=new Array("sparkle.gif",45,46,"sparkle.gif",38,35,"sparkle.gif",30,31,"sparkle.gif",28,26,
"sparkle.gif",22,21,"sparkle.gif",16,16,"sparkle.gif",10,10)
nos=parseInt(T1.length/3)
rate=75
ie5fix1=0;
ie5fix2=0;
for (i=0;i<nos;i++){
createContainer("CUR"+i,i*10,i*10,i*3+1,i*3+2,"","<img src='"+T1[i*3]+"' width="+T1[(i*3+1)]+" height="+T1[(i*3+2)]+" border=0>")}
function createContainer(N,Xp,Yp,W,H,At,HT,Op,St){
with (document){
write((!B) ? "<layer id='"+N+"' left="+Xp+" top="+Yp+" width="+W+" height="+H : "<div id='"+N+"'"+" style='position:absolute;left:"+Xp+"; top:"+Yp+"; width:"+W+"; height:"+H+";");
if(St){
if (C)
write(" style='");
write(St+";' ")
}
else write((B)?"'":"");
write((At)? At+">" : ">");
write((HT) ? HT : "");
if (!Op)
closeContainer(N)
}
}
function closeContainer(){
document.write((B)?"</div>":"</layer>")
}
function getXpos(N){
return (B) ? parseInt(B[N].style.left) : C[N].left
}
function getYpos(N){
return (B) ? parseInt(B[N].style.top) : C[N].top
}

function moveContainer(N,DX,DY){
c=(B) ? B[N].style :C[N];c.left=DX;c.top=DY
}
function cycle(){
//if (IE5)
if (document.all&&window.print){
ie5fix1=document.body.scrollLeft;
ie5fix2=document.body.scrollTop;
}
for (i=0;i<(nos-1);i++){
moveContainer("CUR"+i,getXpos("CUR"+(i+1)),getYpos("CUR"+(i+1)))
}
}
function newPos(e){
moveContainer("CUR"+(nos-1),(B)?event.clientX+ie5fix1:e.pageX+2,(B)?event.clientY+ie5fix2:e.pageY+2
)
}
if(document.layers)
document.captureEvents(Event.MOUSEMOVE)
document.onmousemove=newPos
setInterval("cycle()",rate)
// -->

internet explorer mi segnala un errore al rigo 40 carattere 26, ma non riesco a capire il motivo...

Offline dinox

  • Esploratore
  • **
  • Post: 92
    • Mostra profilo
Re:Effetto javascript scia che segue il mouse
« Risposta #1 il: 06 Set 2009, 11:00:17 »
Volevo aggoungere che il codice javascript funziona se aggiunto a una pagina html, il problema e solo relativo all'integrazione con Joomla.

Offline redtooth

  • Nuovo arrivato
  • *
  • Post: 40
    • Mostra profilo
Re:Effetto javascript scia che segue il mouse
« Risposta #2 il: 06 Set 2009, 11:37:19 »
il file mouse.js lo hai uploadato sul server nella cartella /media/system/js/?

Offline dinox

  • Esploratore
  • **
  • Post: 92
    • Mostra profilo
Re:Effetto javascript scia che segue il mouse
« Risposta #3 il: 06 Set 2009, 12:30:01 »
si, il problema è che se lo metto in una normale pagina html funziona, se lo aggiungo all'index del template di joomla, mi esce l'icona modificata ma rimane in altro a sinistra senza seguire il mouse...

Offline redtooth

  • Nuovo arrivato
  • *
  • Post: 40
    • Mostra profilo
Re:Effetto javascript scia che segue il mouse
« Risposta #4 il: 06 Set 2009, 16:08:29 »
Ho provato e a me funziona correttamente. (Occhio che ho sostituito i nomi dei file visto che ho copiato lo script da un altro sito)
Codice da copiare nella sezione BODY:
Codice: [Seleziona]
// Cross browser cursor trailer script- By Brian Caputo (bcaputo@icdc.com)



A=document.getElementById
B=document.all;
C=document.layers;
T1=new Array("trail1.gif",38,35,"trail2.gif",30,31,"trail3.gif",28,26,"trail4.gif",22,21,"trail5.gif",16,16,"trail6.gif",10,10)

var offsetx=15 //x offset of trail from mouse pointer
var offsety=10 //y offset of trail from mouse pointer

nos=parseInt(T1.length/3)
rate=50
ie5fix1=0;
ie5fix2=0;
rightedge=B? document.body.clientWidth-T1[1] : window.innerWidth-T1[1]-20
bottomedge=B? document.body.scrollTop+document.body.clientHeight-T1[2] : window.pageYOffset+window.innerHeight-T1[2]

for (i=0;i<nos;i++){
createContainer("CUR"+i,i*10,i*10,i*3+1,i*3+2,"","<img src='"+T1[i*3]+"' width="+T1[(i*3+1)]+" height="+T1[(i*3+2)]+" border=0>")
}

function createContainer(N,Xp,Yp,W,H,At,HT,Op,St){
with (document){
write((!A && !B) ? "<layer id='"+N+"' left="+Xp+" top="+Yp+" width="+W+" height="+H : "<div id='"+N+"'"+" style='position:absolute;left:"+Xp+"; top:"+Yp+"; width:"+W+"; height:"+H+"; ");
if(St){
if (C)
write(" style='");
write(St+";' ")
}
else write((A || B)?"'":"");
write((At)? At+">" : ">");
write((HT) ? HT : "");
if (!Op)
closeContainer(N)
}
}

function closeContainer(){
document.write((A || B)?"</div>":"</layer>")
}

function getXpos(N){
if (A)
return parseInt(document.getElementById(N).style.left)
else if (B)
return parseInt(B[N].style.left)
else
return C[N].left
}

function getYpos(N){
if (A)
return parseInt(document.getElementById(N).style.top)
else if (B)
return parseInt(B[N].style.top)
else
return C[N].top
}

function moveContainer(N,DX,DY){
c=(A)? document.getElementById(N).style : (B)? B[N].style : (C)? C[N] : "";
if (!B){
rightedge=window.innerWidth-T1[1]-20
bottomedge=window.pageYOffset+window.innerHeight-T1[2]
}
c.left=Math.min(rightedge, DX+offsetx);
c.top=Math.min(bottomedge, DY+offsety);
}
function cycle(){
//if (IE5)
if (document.all&&window.print){
ie5fix1=document.body.scrollLeft;
ie5fix2=document.body.scrollTop;
}
for (i=0;i<(nos-1);i++){
moveContainer("CUR"+i,getXpos("CUR"+(i+1)),getYpos("CUR"+(i+1)))
}
}

function newPos(e){
moveContainer("CUR"+(nos-1),(B)?event.clientX+ie5fix1:e.pageX+2,(B)?event.clientY+ie5fix2:e.pageY+2)
}

function getedgesIE(){
rightedge=document.body.clientWidth-T1[1]
bottomedge=document.body.scrollHeight-T1[2]
}

if (B){
window.onload=getedgesIE
window.onresize=getedgesIE
}

if(document.layers)
document.captureEvents(Event.MOUSEMOVE)
document.onmousemove=newPos
setInterval("cycle()",rate)
</script>
« Ultima modifica: 06 Set 2009, 16:11:35 da redtooth »

Offline dinox

  • Esploratore
  • **
  • Post: 92
    • Mostra profilo
Re:Effetto javascript scia che segue il mouse
« Risposta #5 il: 06 Set 2009, 17:18:05 »
 ;)
« Ultima modifica: 21 Set 2009, 14:36:49 da dinox »

 



Web Design Bolzano Kreatif