Listing du fichier tp4ex1.js
00001// (gH) -_- tp4ex1.js ; TimeStamp (unix) : 28 Mars 2010 vers 14:50
00002
00003 // ######################################################################
00004
00005 function creation() {
00006
00007 // ######################################################################
00008
00009 // partie du haut
00010
00011 eltpa = window.document.createElement("p") ;
00012 eltpa.setAttribute("id","p1") ;
00013 text0 = window.document.createTextNode("Bonjour") ;
00014 text1 = window.document.createTextNode(" les ") ;
00015 text2 = window.document.createTextNode("petits") ;
00016 text3 = window.document.createTextNode(" enfants !") ;
00017 eltsp = window.document.createElement("span") ;
00018 eltgr = window.document.createElement("b") ;
00019
00020 eltsp.appendChild(eltgr) ;
00021 eltsp.setAttribute("class","gbleu") ;
00022 eltsp.setAttribute("className","gbleu") ;
00023 eltgr.appendChild(text2) ;
00024
00025 eltpa.appendChild(text0) ;
00026 eltpa.appendChild(text1) ;
00027 eltpa.appendChild(eltsp) ;
00028 eltpa.appendChild(text3) ;
00029
00030 window.document.body.appendChild(eltpa) ;
00031
00032 // partie du bas
00033
00034 eltp2 = window.document.createElement("p") ;
00035 eltah = window.document.createElement("a") ;
00036 texte = window.document.createTextNode(" cliquez moi ") ;
00037 eltah.setAttribute("href","non.php") ;
00038 eltah.setAttribute("onclick","changement() ; return false ") ;
00039 eltah.setAttribute("class","bouton_rectangulaire vert_pastel") ;
00040 eltah.setAttribute("className","bouton_rectangulaire vert_pastel nou") ;
00041
00042 eltah.appendChild(texte) ;
00043 eltp2.appendChild(eltah) ;
00044 window.document.body.appendChild(eltp2) ;
00045
00046 } ; // fin de fonction creation
00047
00048 // ######################################################################
00049
00050 function changement() {
00051
00052 // ######################################################################
00053
00054 while (window.document.body.firstChild) {
00055 window.document.body.removeChild(window.document.body.firstChild )
00056 } ; // fin de tant que
00057
00058 nouvh1 = window.document.createElement("h1") ;
00059 nouvtx = window.document.createTextNode("Bonsoir") ;
00060 nouvh1.appendChild(nouvtx) ;
00061 window.document.body.appendChild(nouvh1) ;
00062
00063 } ; // fin de fonction changement
00064
00065 // ######################################################################
00066
Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.
Retour à la page principale de (gH)