Newsgroup: it.comp.lang.javascript
Titolo: Script che non funziona con Navigator 6

Sul mio sito per visualizzare i dati uso una nuova finestra (window.open) in cui si 
apre, grazie ad un codice javascript, un ulteriore finestra in cui è visualizzato il 
file con i dati. Se andate a vedere le singole pagine dei risultati pubblicati tutto vi 
sarà più chiaro.
Qui di seguito vi è il codice, che sottolineo, non è mio, ma mi è stato passato così 
com'era. Per funzionare vi sono altre righe di codice javascript anche nella 
pagina dei dati.
<HTML> 
<HEAD> 
<TITLE>USA Indoor Championships 2001-WWRW</TITLE> 
<META http-equiv=Content-Type content="text/html; charset=windows-1252"> 
<SCRIPT language=JavaScript> 
<!-- 
n = (document.layers) ? 1:0 
ie = (document.all) ? 1:0 
// Scroll Bar Setup Variables 
scrollLeft = 20 
scrollTop = 100 
scrollNestLeft = 0 
scrollNestTop = 0 
scrollWidth = 640 
scrollHeight = 360 
scrollBarWidth = 12 
scrollBoxHeight = 30 
scrollArrowHeight = 12 
scrollMarginLeft = 10 
scrollMarginRight = 10 
scrollMarginTop = 10 
scrollMarginBottom = 10 
scrollBorder = 1 
scrollBorderColor = "#000000" 
scrollBarColor = "#CCCCCC" 
scrollBoxColor = "#000000" 
scrollArrowColor = "#666666" 
scrollTextBGColor = "#FFFFFF" 
scrollFirstPage = "usa1101.htm" 
scrollLoaded = 0 
scrollActive = 0 
scrollArrowActive = 0 
scrollDownActive = 0 
scrollYold = 0 
scrollClickY = 0 
scrollBarHeight = scrollHeight-2*scrollBorder-scrollBoxHeight-scrollArrowHeight 
function init() { 
document.onmousedown = mouseDown 
document.onmousemove = mouseMove 
document.onmouseup = mouseUp 
if (n) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | 
Event.MOUSEUP) 
} 
function mouseDown(e) { 
if ((n && e.which == 1) || ie) { 
if (n) {var x=e.pageX; var y=e.pageY} 
if (ie) {var x=event.x; var y=event.y} 
scrollMouseDown(x,y) 
} 
} 
function mouseMove(e) { 
if (n) {var x=e.pageX; var y=e.pageY} 
if (ie) {var x=event.x; var y=event.y} 
if (scrollLoaded && scrollActive) { 
scrollMouseMove(x,y) 
} 
if (scrollActive || scrollArrowActive) return false 
} 
function mouseUp(e) { 
scrollActive = 0 
scrollArrowActive = 0 
scrollDownActive = 0 
} 
function scrollMouseDown(x,y) { 
if (scrollLoaded && scrollFactor<0 && x>=scrollLeft+scrollNestLeft+scrollWidth-
scrollBarWidth-scrollBorder && x<(scrollLeft+scrollNestLeft)+scrollWidth-
scrollBorder && y>=(scrollTop+scrollNestTop)+scrollBorder && 
y<(scrollTop+scrollNestTop)+scrollHeight-scrollBorder) { 
if (y>=scrollTop+scrollNestTop+scrollBorder+scrollbox.y && 
y<(scrollTop+scrollNestTop)+scrollBorder+scrollBoxHeight+scrollbox.y) { // 
scrollbox 
scrollClickY = y-scrollbox.y 
scrollYold = y 
scrollActive = 1 
} 
else if (y<scrollTop+scrollNestTop+scrollBorder+scrollArrowHeight) { // up arrow 
scrollArrowActive = 1 
scrollArrowDir = 1 
scrollArrowSlide() 
} 
else if (y>=scrollTop+scrollNestTop+scrollHeight-scrollBorder-scrollArrowHeight) { 
// down arrow 
scrollArrowActive = 1 
scrollArrowDir = -1 
scrollArrowSlide() 
} 
else { 
if 
(y<=scrollTop+scrollNestTop+scrollBorder+scrollArrowHeight+scrollBoxHeight/2) { 
// jump top 
scrollbox.moveTo(0,scrollArrowHeight) 
} 
else if (y>scrollTop+scrollNestTop+scrollHeight-scrollBorder-scrollArrowHeight-
scrollBoxHeight/2) { // jump bottom 
scrollbox.moveTo(0,scrollBarHeight) 
} 
else { // jump middle 
scrollbox.moveTo(0,y-scrollTop-scrollNestTop-scrollBorder-scrollBoxHeight/2) 
} 
scrolltext.moveTo(scrolltext.x,scrollFactor*(scrollbox.y-
scrollArrowHeight)+scrollMarginTop) 
scrollClickY = y-scrollbox.y 
scrollYold = y 
scrollActive = 1 
} 
} 
} 
function scrollMouseMove(x,y) { 
var diff = y-scrollYold 
if ((scrollbox.y>scrollArrowHeight && scrollbox.y<scrollBarHeight) || 
(scrollbox.y==scrollArrowHeight && diff>=0) || (scrollbox.y==scrollBarHeight && 
diff<=0)) { 
if ((scrollbox.y>scrollArrowHeight && scrollbox.y+diff<scrollArrowHeight) || 
(scrollbox.y<scrollBarHeight && scrollbox.y+diff>scrollBarHeight)) { 
if (scrollbox.y+diff<scrollArrowHeight) scrollbox.moveTo(0,scrollArrowHeight) 
else if (scrollbox.y+diff>scrollBarHeight) scrollbox.moveTo(0,scrollBarHeight) 
scrollYold = scrollbox.y+scrollClickY 
} 
else { 
scrollbox.moveTo(0,y-scrollClickY) 
scrollYold = y 
} 
scrolltext.moveTo(scrolltext.x,scrollFactor*(scrollbox.y-
scrollArrowHeight)+scrollMarginTop) 
} 
} 
function scrollArrowSlide() { 
if (scrollArrowActive) { 
if ((scrollArrowDir==1 && scrolltext.y<scrollMarginTop-5) || (scrollArrowDir==-1 
&& scrolltext.y>-(scrolltext.height+2*scrollBorder+scrollMarginBottom-scrollHeight-
5))) { 
scrolltext.moveBy(0,scrollArrowDir*5) 
scrollbox.moveTo(0,(scrolltext.y-scrollMarginTop)/scrollFactor+scrollArrowHeight) 
setTimeout("scrollArrowSlide()",20) 
} 
else { 
if (scrollArrowDir==1) scrolltext.moveTo(scrolltext.x,scrollMarginTop) 
else if (scrollArrowDir==-1) scrolltext.moveTo(scrolltext.x,-
(scrolltext.height+2*scrollBorder+scrollMarginBottom-scrollHeight)) 
scrollbox.moveTo(0,(scrolltext.y-scrollMarginTop)/scrollFactor+scrollArrowHeight) 
} 
} 
} 
function loadSource(page) { 
scrollLoaded = 0 
if (n) document.scrollWindow.document.scrollTextWindow.src = page 
if (ie) parent.scrollTextFrame.document.location = page 
} 
function scrollResize() { 
scrolltext = new 
dynLayer("scrollTextDiv","scrollWindow.document.scrollTextWindow","scrollTextFr
ame") 
scrollbox = new dynLayer("scrollBoxDiv","scrollWindow.document.scrollBar") 
scrollFactor = -(scrolltext.height+scrollMarginTop+scrollMarginBottom-
scrollHeight+2*scrollBorder)/(scrollBarHeight-scrollArrowHeight) 
scrollbox.moveTo(0,scrollArrowHeight) 
scrollLoaded = 1 
} 
function dynLayer(id,nestref,frameref) { 
if (n) { 
if (nestref) { 
this.css = eval("document." + nestref + ".document." + id) 
this.ref = eval("document." + nestref + ".document." + id + ".document") 
} 
else { 
this.css = document.layers[id] 
this.ref = document.layers[id].document 
} 
this.x = this.css.left 
this.y = this.css.top 
this.width = this.ref.width 
this.height = this.ref.height 
} 
else if (ie) { 
if (frameref) { 
this.css = parent.frames[frameref].document.all[id].style 
this.ref = parent.frames[frameref].document 
} 
else { 
this.css = document.all[id].style 
this.ref = document 
} 
this.x = this.css.pixelLeft 
this.y = this.css.pixelTop 
this.width = this.ref.all[id].offsetWidth 
this.height = this.ref.all[id].offsetHeight 
} 
this.obj = id + "Object" 
eval(this.obj + "=this") 
this.moveBy = dynLayerMoveBy 
this.moveTo = dynLayerMoveTo 
this.show = dynLayerShow 
this.hide = dynLayerHide 
} 
function dynLayerMoveBy(x,y) { 
this.x += x 
this.css.left = this.x 
this.y += y 
this.css.top = this.y 
} 
function dynLayerMoveTo(x,y) { 
this.x = x 
this.css.left = this.x 
this.y = y 
this.css.top = this.y 
} 
function dynLayerShow() { 
if (n) this.css.visibility = "show" 
else if (ie) this.css.visibility = "visible" 
} 
function dynLayerHide() { 
if (n) this.css.visibility = "hide" 
else if (ie) this.css.visibility = "hidden" 
} 
//--> 
</SCRIPT><META content="MSHTML 5.50.4134.600" 
name=GENERATOR></HEAD><BODY bgColor=#FFFFFF onload=init()> 
<div align=center> 
<p align=center><font face=Arial size=5><b>USA Indoor Championships 
2001</b></font></p> 
<p align=center><font face=Arial size=2><b>02-03/03/2001 Atlanta 
(USA)</b></font></p> 
<p align=center> 
<SCRIPT language=JavaScript> 
document.writeln('<STYLE TYPE="text/css">'); 
document.writeln('<\!--'); 
document.writeln('#scrollWindow {position:absolute; left:'+scrollLeft+'; 
top:'+scrollTop+'; width:'+scrollWidth+'; height:'+scrollHeight+'; 
clip:rect(0,'+scrollWidth+','+scrollHeight+',0);}'); 
document.writeln('#scrollBorderTop {position:absolute; left:0; top:0; 
width:'+scrollWidth+'; height:'+scrollBorder+'; 
clip:rect(0,'+scrollWidth+','+scrollBorder+',0); background-
color:'+scrollBorderColor+'; layer-background-color:'+scrollBorderColor+';}'); 
document.writeln('#scrollBorderBottom {position:absolute; left:0; 
top:'+(scrollHeight-scrollBorder)+'; width:'+scrollWidth+'; height:'+scrollBorder+'; 
clip:rect(0,'+scrollWidth+','+scrollBorder+',0); background-
color:'+scrollBorderColor+'; layer-background-color:'+scrollBorderColor+';}'); 
document.writeln('#scrollBorderLeft {position:absolute; left:0; top:0; 
width:'+scrollBorder+'; height:'+scrollHeight+'; 
clip:rect(0,'+scrollBorder+','+scrollHeight+',0); background-
color:'+scrollBorderColor+'; layer-background-color:'+scrollBorderColor+';}'); 
document.writeln('#scrollBorderRight {position:absolute; left:'+(scrollWidth-
scrollBorder)+'; top:0; width:'+scrollBorder+'; height:'+scrollHeight+'; 
clip:rect(0,'+scrollBorder+','+scrollHeight+',0); background-
color:'+scrollBorderColor+'; layer-background-color:'+scrollBorderColor+';}'); 
if (ie) document.writeln('#scrollTextWindow {position:absolute; 
left:'+scrollBorder+'; top:'+scrollBorder+'; width:'+(scrollWidth-scrollBarWidth-
2*scrollBorder)+'; height:'+(scrollHeight-2*scrollBorder)+'; 
clip:rect(0,'+(scrollWidth-scrollBarWidth-2*scrollBorder)+','+(scrollHeight-
2*scrollBorder)+',0); background-color:'+scrollTextBGColor+'; layer-background-
color:'+scrollTextBGColor+';}'); 
document.writeln('#scrollBar {position:absolute; left:'+(scrollWidth-scrollBarWidth-
scrollBorder)+'; top:'+scrollBorder+'; width:'+scrollBarWidth+'; 
height:'+(scrollHeight-2*scrollBorder)+'; 
clip:rect(0,'+scrollBarWidth+','+(scrollHeight-2*scrollBorder)+',0); background-
color:'+scrollBarColor+'; layer-background-color:'+scrollBarColor+';}'); 
if (scrollBoxColor=="none") document.writeln('#scrollBoxDiv {position:absolute; 
left:0; top:0; width:'+scrollBarWidth+'; height:'+scrollBoxHeight+'; 
clip:rect(0,'+scrollBarWidth+','+scrollBoxHeight+',0);}'); 
else document.writeln('#scrollBoxDiv {position:absolute; left:0; 
top:'+scrollArrowHeight+'; width:'+scrollBarWidth+'; height:'+scrollBoxHeight+'; 
clip:rect(0,'+scrollBarWidth+','+scrollBoxHeight+',0); background-
color:'+scrollBoxColor+'; layer-background-color:'+scrollBoxColor+';}'); 
document.writeln('#scrollArrowUpDiv {position:absolute; left:0; top:0; 
width:'+scrollBarWidth+'; height:'+scrollArrowHeight+'; 
clip:rect(0,'+scrollBarWidth+','+scrollArrowHeight+',0); background-
color:'+scrollArrowColor+'; layer-background-color:'+scrollArrowColor+';}'); 
document.writeln('#scrollArrowDownDiv {position:absolute; left:0; 
top:'+(scrollHeight-2*scrollBorder-scrollArrowHeight)+'; width:'+scrollBarWidth+'; 
height:'+scrollArrowHeight+'; 
clip:rect(0,'+scrollBarWidth+','+scrollArrowHeight+',0); background-
color:'+scrollArrowColor+'; layer-background-color:'+scrollArrowColor+';}'); 
document.writeln('-->'); 
document.writeln('</STYLE>'); 
</SCRIPT> 
</p> 
</div> 
<DIV id=scrollWindow> 
<DIV id=scrollBar> 
<DIV id=scrollBoxDiv></DIV> 
<DIV id=scrollArrowUpDiv></DIV> 
<DIV id=scrollArrowDownDiv></DIV></DIV> 
<DIV id=scrollBorderTop></DIV> 
<DIV id=scrollBorderBottom></DIV> 
<DIV id=scrollBorderLeft></DIV> 
<DIV id=scrollBorderRight></DIV> 
<SCRIPT language=JavaScript> 
if (n) document.writeln('<LAYER NAME="scrollTextWindow" 
SRC="'+scrollFirstPage+'" LEFT='+scrollBorder+' TOP='+scrollBorder+' 
WIDTH='+(scrollWidth-scrollBarWidth-2*scrollBorder)+' HEIGHT='+(scrollHeight-
2*scrollBorder)+' CLIP="0,0,'+(scrollWidth-scrollBarWidth-
2*scrollBorder)+','+(scrollHeight-2*scrollBorder)+'" 
BGCOLOR="'+scrollTextBGColor+'"></LAYER>') 
if (ie) document.writeln('<DIV ID="scrollTextWindow"><IFRAME 
NAME="scrollTextFrame" SRC="'+scrollFirstPage+'" WIDTH='+(scrollWidth-
scrollBarWidth-2*scrollBorder)+' HEIGHT='+(scrollHeight-2*scrollBorder)+' 
MARGINWIDTH=0 MARGINHEIGHT=0 FRAMEBORDER="No" 
SCROLLING="No"></IFRAME></DIV>') 
</SCRIPT> 
</DIV></BODY></HTML> 
Vorrei sapere perché con IE funziona, con Netscape Navigator 4.x (per Windows 
e Linux) funziona e con Netscape Navigator 6 si apre regolarmente la finestra (in 
questo caso usa1101f.htm) e non il file interno (in questo caso usa1101.htm).
A maggiore completezza d'informazione vi dico che i due file sono nella stessa 
directory e nulla è valso inserire come riferimento l'esatto percorso del file 
(
http://www.worldwideracewalking.com/2001/03-2001/usa1101.htm
 
Se avete qualche idea in proposito fatemi sapere. 
Grazie 
MrVain 
http://www.worldwideracewalking.com
 
ben...@worldwideracewalking.com
 
-- 
Posted from 
blossom.yourdomainregister.com
 [216.71.84.193] 
via Mailgate.ORG Server - 
http://www.Mailgate.ORG

 Se avete qualche idea in proposito fatemi sapere.
Premetto che non ho guardato a fondo lo script (solo perchè è lungo e
incasinato), ma penso che l'unico che ti possa dare risposta sia l'autore
dello script stesso. In netscape 6 sono state fatte delle migliorie nella
gestione degli oggetti ma, nello stesso tempo, sono state eliminate le
direttive tipiche delle vecchie versioni. La gestione con NS6 degli oggetti
avviene tramite GetElementById (o qualcosa del genere); evidentemente lo
script è datato e non prevede questa variante.
Ciao!
Davide