Voici un exemple simple pour créer une "classe" en javascript, à vous de juger...
<div id='idTest'>Marche pas encore...</div>
<script>
/**
* Mon objet(class)
*/
function monObj(){
/**
* Exemple de vars propre à l'objet
*/
if(document.getElementById) this.GET_ELEMENT_BY_ID=new Function("id","return document.getElementById(id);");
else if(document.all) this.GET_ELEMENT_BY_ID=new Function("id","return document.all[id];");
else if(document.layers) this.GET_ELEMENT_BY_ID=new Function("id","return document.layers[id];");
// =========================
/**
* Exemple d'utilisation
*/
this.writeID=function(id,html){
this.getElementById(id).innerHTML=html;
}
// =========================
}
/****** TESTS TESTS TESTS ******/
try {
// Instance
var monObj=new monObj();
monObj.writeID('idTest','abengadon ça fonctionne');
}
// Err
catch(e) {
alert(e);
}
/****** TESTS TESTS TESTS ******/
</script>