Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2009
    Messaggi
    2

    problema JS div is null

    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

  2. #2
    ma esiste un elemento con id="mainTable"? Se si, dove lo metti lo script?
    I DON'T Double Click!

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2009
    Messaggi
    2
    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

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.