Ciao a tutti.
Premetto che sono veramente un newby sia sul forum sia col javascript.
Ho trovato uno script (Bak2Top di MaxxBlade) che permette di effettuare il "salto" alla top page sfruttando un'immagine che compare una volta che inizia lo scroll verso il basso e che segue a distanza costante dal bordo inferiore.
L'ho modificato leggermente in modo da avere la doppia immagine (dx e sx) e in modo che, centrando la pagina, le img seguano a seconda della risoluzione usata.
Il problema è che se lo testo su IE va tutto bene, mentre su Mozilla mi sposta le img di 8 px a dx, uscendo dalla pagina (dx) e entrando nel testo (sx).
VVoVe:
Ho provato ad usare lo script proposto su pro.html.it per riconoscere il browser e dare uno scarto differente a Mozilla, ma è come se non avessi scritto nulla. Qualcuno mi può aiutare, per favore? Ecco lo script:
codice:
/* btts = delay of img blinking
bttx = width of div/main win
btty = img height from bottom
bttc = img path bttcx = img path for ie
widimg = img width widimgdx = IE-Moz difference */
var btts=150, bttx=800, btty=150, bttcx='[img]../Imgs/phenix_up.gif[/img]', bttc='[img]../Imgs/phenix_up.png[/img]', widimg=40, widimgdx=8;
function winWid(){ return (ns4||ns6)?window.innerWidth:document.body.clientWidth; }
function winHei(){ return (ns4||ns6)?window.innerHeight:document.body.clientHeight; }
function winOfy(){ return (ns4||ns6)?window.pageYOffset:document.body.scrollTop; }
// Recognization of browser to apply the correct parameters (img rh)
if (document.layers)
{ //Netscape 4.x
function mtoplink(){ with(eval(bttll)){ left=(winOfy()>0)?((winWid()+bttx)/2)-widimg:-500; top=(winOfy()>0)?winHei()-btty+winOfy():-500; } setTimeout('mtoplink()',btts); };
function toplink(){ rt=(!ns4)?'<div id="bttl" style="position:absolute;">':'<layer name="bttl">';
rt+=(!ns4)?'<a style="cursor: '+hand+'" onclick':'<a href"'; rt+='="JavaScript:scrollTo(0,0)">';
rt+=bttcx; rt+=(!ns4)?'</a></div>':'</a></layer>'; document.write(rt); mtoplink(); };
}
else if (document.all)
{ // Explorer
function mtoplink(){ with(eval(bttll)){ left=(winOfy()>0)?((winWid()+bttx)/2)-widimg:-500; top=(winOfy()>0)?winHei()-btty+winOfy():-500; } setTimeout('mtoplink()',btts); };
function toplink(){ rt=(!ns4)?'<div id="bttl" style="position:absolute;">':'<layer name="bttl">';
rt+=(!ns4)?'<a style="cursor: '+hand+'" onclick':'<a href"'; rt+='="JavaScript:scrollTo(0,0)">';
rt+=bttcx; rt+=(!ns4)?'</a></div>':'</a></layer>'; document.write(rt); mtoplink(); };
}
else if (document.getElementById)
{ //Netscape 6.x
function mtoplink(){ with(eval(bttll)){ left=(winOfy()>0)?((winWid()+bttx)/2)-(widimg+widimgdx):-500; top=(winOfy()>0)?winHei()-btty+winOfy():-500; } setTimeout('mtoplink()',btts); };
function toplink(){ rt=(!ns4)?'<div id="bttl" style="position:absolute;">':'<layer name="bttl">';
rt+=(!ns4)?'<a style="cursor: '+hand+'" onclick':'<a href"'; rt+='="JavaScript:scrollTo(0,0)">';
rt+=bttc; rt+=(!ns4)?'</a></div>':'</a></layer>'; document.write(rt); mtoplink(); };
}
// Recognization of browser to apply the correct parameters (img lh)
if (document.layers)
{ //Netscape 4.x
function mtoplinklex(){ with(eval(bttlllex)){ left=(winOfy()>0)?((winWid()-bttx)/2)-widimg:-500; top=(winOfy()>0)?winHei()-btty+winOfy():-500; } setTimeout('mtoplinklex()',btts); };
function toplinklex(){ rt=(!ns4)?'<div id="bttllex" style="position:absolute;">':'<layer name="bttllex">';
rt+=(!ns4)?'<a style="cursor: '+hand+'" onclick':'<a href"'; rt+='="JavaScript:scrollTo(0,0)">';
rt+=bttcx; rt+=(!ns4)?'</a></div>':'</a></layer>'; document.write(rt); mtoplinklex(); };
}
else if (document.all)
{ // Explorer
function mtoplinklex(){ with(eval(bttlllex)){ left=(winOfy()>0)?((winWid()-bttx)/2):-500; top=(winOfy()>0)?winHei()-btty+winOfy():-500; } setTimeout('mtoplinklex()',btts); };
function toplinklex(){ rt=(!ns4)?'<div id="bttllex" style="position:absolute;">':'<layer name="bttllex">';
rt+=(!ns4)?'<a style="cursor: '+hand+'" onclick':'<a href"'; rt+='="JavaScript:scrollTo(0,0)">';
rt+=bttcx; rt+=(!ns4)?'</a></div>':'</a></layer>'; document.write(rt); mtoplinklex(); };
}
else if (document.getElementById)
{ //Netscape 6.x
function mtoplinklex(){ with(eval(bttlllex)){ left=(winOfy()>0)?((winWid()-bttx)/2)-widimgdx:-500; top=(winOfy()>0)?winHei()-btty+winOfy():-500; } setTimeout('mtoplinklex()',btts); };
function toplinklex(){ rt=(!ns4)?'<div id="bttllex" style="position:absolute;">':'<layer name="bttllex">';
rt+=(!ns4)?'<a style="cursor: '+hand+'" onclick':'<a href"'; rt+='="JavaScript:scrollTo(0,0)">';
rt+=bttc; rt+=(!ns4)?'</a></div>':'</a></layer>'; document.write(rt); mtoplinklex(); };
}
var ns4=(document.layers)?1:0;
var ie4=(document.all)?1:0;
var ns6=(document.getElementById&&!document.all)?1:0;
var hand=(ie4)?'hand':'pointer';
if(ie4) bttll="document.all['bttl'].style";
if(ns4) bttll="document.layers['bttl']";
if(ns6) bttll="document.getElementById('bttl').style";
if(ie4) bttlllex="document.all['bttllex'].style";
if(ns4) bttlllex="document.layers['bttllex']";
if(ns6) bttlllex="document.getElementById('bttllex').style";
toplink();
toplinklex()
Grazie!!