Newsgroup: it.comp.lang.javascript
Titolo: errore che non capisco

io ho questo script che in IE5 mi da il seguente errore:
riga 130
carattere 1
Errore 'document.body' non e' un oggetto
Non capisco dove sbaglio :-(
<HTML>
<HEAD>
<SCRIPT Language="JavaScript">
<!-- determina la risoluzione dello schermo -->
if (window.screen){
var w=screen.width
var h=screen.height
if (h<580 & w<740){
document.writeln("<LINK REL=stylesheet  type=text/css
HREF=../../css/position640.css>");}
else if (h<674 & w<835){
document.writeln("<LINK REL=stylesheet  type=text/css
HREF=../../css/position800.css>");}
else {
document.writeln("<LINK REL=stylesheet  type=text/css
HREF=../../css/position.css>");}
}
<!-- immagini che non scrollano -->
function resetFix() {
document.all.iewrap2.style.posTop = document.body.scrollTop;
document.all.iewrap2.style.posLeft = document.body.scrollLeft;
}
<!-- descrizioni nel telecomando -->
  var totalLayersInLoop=11;
 var layerNumShowing=1;
 function init(){
          if (navigator.appName == "Netscape") {
      layerStyleRef="layer.";
    layerRef="document.layers";
   styleSwitch="";
   }else{
    layerStyleRef="layer.style.";
   layerRef="document.all";
    styleSwitch=".style";
   }  }
 function showLayerNumber(number){
   var layerNumToShow=number;
  hideLayer(eval('"layer' + layerNumShowing+'"'));
   showLayer(eval('"layer' + layerNumToShow+'"'));
   layerNumShowing=layerNumToShow;   }
 function showLayer(layerName){
 eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');  }
 function hideLayer(layerName){
   eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');  }
<!-- telecomando -->
<!-- set below variable to false if you wish to turn off "fade-off" effect
for IE 4 users -->
var enableeffect=true
if (document.layers)
document.dropmenu01.document.dropmenu02.visibility='show'
function dropit2(){
if (document.all){
dropmenu03.style.left=document.body.scrollLeft+event.clientX-event.offsetX
dropmenu03.style.top=document.body.scrollTop+event.clientY-event.offsetY+18
if (dropmenu03.style.visibility=="hidden"){
if (enableeffect)
dropmenu03.filters.revealTrans.apply()
dropmenu03.style.visibility="visible"
if (enableeffect)
dropmenu03.filters.revealTrans.play()
}
else{
hidemenu()
}
}
}
function dropit(e){
if (document.dropmenu03.visibility=="hide")
document.dropmenu03.visibility="show"
else
document.dropmenu03.visibility="hide"
document.dropmenu03.left=e.pageX-e.layerX
document.dropmenu03.top=e.pageY-e.layerY+19
return false
}
function hidemenu(){
if (enableeffect)
dropmenu03.filters.revealTrans.stop()
dropmenu03.style.visibility="hidden"
}
function hidemenu2(){
document.dropmenu03.visibility="hide"
}
if (document.layers){
document.dropmenu01.document.dropmenu02.captureEvents(Event.CLICK)
document.dropmenu01.document.dropmenu02.onclick=dropit
}
else if (document.all)
document.body.onclick=hidemenu
</SCRIPT>
</HEAD>
<BODY ONLOAD="init()" ONSCROLL="resetFix()"
BACKGROUND="../../sfondi/ciencio3b.gif" BGCOLOR="#C0C0C0" TEXT="#000000"
link=red alink=red vlink=red BGPROPERTIES=FIXED SCROLL=AUTO>
<ilayer id="dropmenu01" height=35px>
<layer id="dropmenu02" visibility=show>
<span id="iewrap">
<span id="iewrap2" onClick="dropit2();event.cancelBubble=true;return false">
<center><font face="Verdana"><b><a href="alternate.htm">Chiudi<br><IMG
SRC="../../gif/remote.gif" Border=0><br>Apri</a></b></font></center>
</span>
</span>
</layer>
</ilayer>
<div id="dropmenu03">
<img src="../../gif/telecomando.gif" usemap="#map" border=0>
<MAP NAME="map">
<Area coords="38,148,64,175" A HREF="io.html"
onMouseOver="javascript:showLayerNumber(2)"
onMouseOut="Javascript:showLayerNumber(1)" alt="Chi sono io?">
<Area coords="38,193,64,220" A HREF="storia.html"
onMouseOver="javascript:showLayerNumber(3)"
onMouseOut="Javascript:showLayerNumber(1)" alt="La mia storia a puntate">
<Area coords="38,240,64,267" A HREF="parma.html"
onMouseOver="javascript:showLayerNumber(4)"
onMouseOut="Javascript:showLayerNumber(1)" alt="La mia citta': Parma">
<Area coords="38,288,64,315" A HREF="foto.html"
onMouseOver="javascript:showLayerNumber(5)"
onMouseOut="Javascript:showLayerNumber(1)" alt="Foto">
<Area coords="38,337,64,364" A HREF="contatti.html"
onMouseOver="javascript:showLayerNumber(6)"
onMouseOut="Javascript:showLayerNumber(1)" alt="Contattami">
<Area coords="80,148,106,175" A HREF="english.html"
onMouseOver="javascript:showLayerNumber(7)"
onMouseOut="Javascript:showLayerNumber(1)" alt="English version">
<Area coords="80,193,106,220" A HREF="amici.html"
onMouseOver="javascript:showLayerNumber(8)"
onMouseOut="Javascript:showLayerNumber(1)" alt="amici on line">
<Area coords="80,240,106,267" A HREF="leggi.html"
onMouseOver="javascript:showLayerNumber(9)"
onMouseOut="Javascript:showLayerNumber(1)" alt="leggi un po' qua!!!">
<Area coords="80,288,106,315" A HREF="links.html"
onMouseOver="javascript:showLayerNumber(10)"
onMouseOut="Javascript:showLayerNumber(1)" alt="Links generici">
<Area coords="80,337,106,364" A HREF="xxx.html"
onMouseOver="javascript:showLayerNumber(11)"
onMouseOut="Javascript:showLayerNumber(1)" alt="Links a siti xxx">
</map>
<DIV ID="layer1" ><P><center><FONT COLOR=yellow
SIZE=2></FONT></center></DIV>
<DIV ID="layer2" ><P><center><FONT COLOR=yellow SIZE=2>Chi sono
io?</FONT></center></DIV>
<DIV ID="layer3" ><P><center><FONT COLOR=yellow SIZE=2>La mia
Storia</FONT></center></DIV>
<DIV ID="layer4" ><P><center><FONT COLOR=yellow SIZE=2>La mia città:
Parma</FONT></center></DIV>
<DIV ID="layer5" ><P><center><FONT COLOR=yellow SIZE=2>Qualche
foto</FONT></center></DIV>
<DIV ID="layer6" ><P><center><FONT COLOR=yellow SIZE=2>Vari modi per
contattarmi e conoscermi</FONT></center></DIV>
<DIV ID="layer7" ><P><center><FONT COLOR=yellow SIZE=2>English
Version</FONT></center></DIV>
<DIV ID="layer8" ><P><center><FONT COLOR=yellow SIZE=2>Amici
on-line</FONT></center></DIV>
<DIV ID="layer9" ><P><center><FONT COLOR=yellow SIZE=2>Per essere un essere
umano</FONT></center></DIV>
<DIV ID="layer10" ><P><center><FONT COLOR=yellow SIZE=2>Links
vari</FONT></center></DIV>
<DIV ID="layer11" ><P><center><FONT COLOR=yellow SIZE=2>Links per
adulti</FONT></center></DIV>
</div>
<script language="JavaScript1.2">
if (document.layers){
document.dropmenu03.captureEvents(Event.CLICK)
document.dropmenu03.onclick=hidemenu2
}
</script>
<!-- segue il resto della pagina -->
</BODY>
</HTML>
per il resto la pagina funziona benissimo quindi non riesco neanche a
determinare il perche' della segnalazione.
Qualcuno potrebbe anche dirmi quali parti eliminare se non voglio alcuna
compatibilita' con NS? tanto poi faccio la pagina solo per NS...
Vic

 link=red alink=red vlink=red BGPROPERTIES=FIXED SCROLL=AUTO>
se scrivi
document.body.onclick=hidemenu
nell' <HEAD> , prima di aver creato <BODY>
ti dice senzaltro che non è definito.
Dovresti mettere:
document.body.onclick=hidemenu
all' interno del <BODY>.
Ciao
--
o------------------------------------------------o
            Gianfranco Carlotti
http://space.tin.it/io/gcarlott
 (SoloIE)
 
gica...@tin.it
o-------------------------------------------------------o
                                                   FERRARA
                                                                Italy
o-------------------------------------------------------------------------o

Ciao
ho capito dove e' l'errore, grazie...ma non ho capito come risolverlo...:-(
cioe' come faccio a metterlo nel body e a farglielo leggere...
vic