problema JS div is null

ispooky83

Nuovo Utente
28 Gen 2009
3
0
0
Ciao a tutti,
premetto che non sono un genio di javascript ma devo risolvere un problema che proprio non mi va giu.
Nel codice javascript sottostante serve per ridimensionare un div e funziona alla perfezione su tutti i browser.

Codice:
      var divscrollContent = document.getElementById("mainTable");
       var htmlheightscrollContent= content_height-"60";
       var htmlWidthscrollContent= content_Width-"200";
       divscrollContent.style.height = htmlheightscrollContent + "px";     
       divscrollContent.style.width = htmlWidthscrollContent + "px";

Il fatto è che FF nella console degli errori mi riporta
"divscrollContent is null"

sapreste aiutarmi per eliminare questo errore maledetto???
ciao
grazie
 
Innanzi tutto grazie del benvenuto,

;-)

carico il file JS subito dopo l'header e brima del body.
Nel body, nell'onload richiamo una funzione di cui ho bisogno per passare le dimensioni alla "maintable".
Codice:
<body onload="javascript:calcHeight();" ...


Il codice della funzione praticamente è questo
Codice:
//trova l'altezza della pagina function calcHeight(){
var content_Width=getBrowserWidth( );
var content_height=getBrowserHeight( );
if (BrowserDetect.browser=="Explorer"){         myGetElementById('leftMenu').style.height=content_height;
myGetElementById('mainTable').style.height=content_height-"54";
myGetElementById('mainTable').style.width=content_Width-"197"; 
myGetElementById('divInterno').style.height=content_height-"130"; 
myGetElementById('masterBody').style.marginTop="0px";    
myGetElementById('DivTest').style.height=content_height-"60";
myGetElementById('DivTest').style.width=content_Width-"200";
}
 if(BrowserDetect.browser=="Firefox"){
var divleft = document.getElementById("leftMenu");
var divMainTable = document.getElementById("mainTable");
var divMasterBody = document.getElementById("masterBody");
var htmlheightMainTable= content_height-"60";
divMainTable.style.height = htmlheightMainTable + "px";
divMasterBody.style.marginTop= "0px"; 
var divscrollContent = document.getElementById("mainTable");
var htmlheightscrollContent= content_height-"60";
var htmlWidthscrollContent= content_Width-"200";
divscrollContent.style.height = htmlheightscrollContent + "px";
divscrollContent.style.width = htmlWidthscrollContent + "px";
}
if (BrowserDetect.browser=="Safari"){
var divleft = document.getElementById("leftMenu");
var divInt = document.getElementById("divInterno");
var divMainTable = document.getElementById("mainTable");
var htmlheightInterno= content_height-"170";
divInt.style.height = htmlheightInterno + "px";
var htmlheightMainTable= content_height-"80";
divMainTable.style.height = htmlheightMainTable + "px"; 
mainTable.style.width=content_Width-"197" + "px";
masterBody.style.marginTop="-16px";
//alert(content_Width);
} 
}
window.onresize=function() {
calcHeight(); 
}


E la mainTable è dichiarata in questo modo
Codice:
<div id="mainTable" style="overflow:auto;">

non so...per me è tutto regolare infatti funziona...ma questo problema nella console FF devo risolverlo!
Quale sarà il problema???
Grazie mille
 
Ultima modifica:

Discussioni simili