Visualizzazione dei risultati da 1 a 5 su 5

Discussione: DOM ed IE6

  1. #1

    DOM ed IE6

    secondo voi come mai sto codice su N6 funge e su IE6 non da errore, ma non si vede nulla?
    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>Untitled</title>
    <script language="JavaScript">
    function creaMenu(id,width,x,y){
     var tr,td,div,txt;
     var a=document.getElementsByTagName("body");
     myBody=a.item(0);
     menuDIV=document.createElement("div");
     menuDIV.setAttribute("id",id);
     menuDIV.style.position="absolute";
     menuDIV.style.top=y;
     menuDIV.style.left=x;
     menuDIV.style.width=width;
     menuDIV.className="tab";
     intDIV=document.createElement("div");
     intDIV.className="tab2";
     tab=document.createElement("table");
     tab.setAttribute("border",1);
     tab.setAttribute("cellspacing",0);
     tab.setAttribute("cellpadding",0);
     tr=document.createElement("tr");
     td=document.createElement("td");
     span=document.createElement("span");
     txt=document.createTextNode("Immagine non disponibile")
     span.appendChild(txt);
     td.appendChild(span);
     tr.appendChild(td);
     tab.appendChild(tr);
     intDIV.appendChild(tab);
     menuDIV.appendChild(intDIV);
     myBody.appendChild(menuDIV);
    }
    </script>
    </head>
    <body>
    <input type="button" value="apri" onclick="creaMenu('rino',200,100,100)">
    </body>
    </html>
    c'è qualche errore?
    Ciao e grazie

  2. #2
    Reale_Augello
    Guest

    Dai...

    ... un'occhiata qui:

    function creaMenu(id,width,x,y){

    id e width sono parole riservate, usa altri termini per i parametri.

    Ciao !

  3. #3
    Reale_Augello
    Guest

    Anzi...

    ... prova così:

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>Untitled</title>
    <script language="JavaScript">
    function creaMenu(id,width,x,y){
     var tr,td,div,txt;
     var a=document.getElementsByTagName("body");
     myBody=a.item(0);
     menuDIV=document.createElement("div");
     menuDIV.setAttribute("id",id);
     menuDIV.style.position="absolute";
     menuDIV.style.top=y;
     menuDIV.style.left=x;
     menuDIV.style.width=width;
     menuDIV.className="tab";
     intDIV=document.createElement("div");
     intDIV.className="tab2";
     tab=document.createElement("table");
     corpotab=document.createElement("tbody"); // mancava questo
     tab.setAttribute("border",1);
     tab.setAttribute("cellspacing",0);
     tab.setAttribute("cellpadding",0);
     tr=document.createElement("tr");
     td=document.createElement("td");
     span=document.createElement("span");
     txt=document.createTextNode("Immagine non disponibile")
     span.appendChild(txt);
     td.appendChild(span);
     tr.appendChild(td);
     corpotab.appendChild(tr); // e
     tab.appendChild(corpotab); // questi ;)
     intDIV.appendChild(tab);
     menuDIV.appendChild(intDIV);
     myBody.appendChild(menuDIV);
    }
    </script>
    </head>
    <body>
    <input type="button" value="apri" onclick="creaMenu('rino',200,100,100)">
    </body>
    </html>
    Ecco qui uno script che ho fatto io (se può interessare):

    http://www.maiueb.it/forumhtmlit/creatabella.htm

    Ciao !

  4. #4
    grazie, non so come, ma l'ho risolto...
    Una domandina:
    ma se voglio aggiungere gli attributi onClick,onMouseOver... come devo fare? se li aggiungo come nome.setAttribute("att",val); funzionano solo su N6

  5. #5
    Utente di HTML.it
    Registrato dal
    Jan 2002
    Messaggi
    633
    Alcuni miei articoli in PRO.HTML.IT: JavaScript | DHTML | DOM
    Sviluppo : wedev | forum

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.