Ver Mensaje Individual
  #5 (permalink)  
Antiguo 09/03/2007, 11:10
Avatar de MaBoRaK
MaBoRaK
 
Fecha de Ingreso: abril-2003
Ubicación: La Paz - Bolivia
Mensajes: 2.003
Antigüedad: 21 años, 9 meses
Puntos: 35
Re: Preguntas sobre ficheros .js

loading.........


Exacto!
Mucho en javascript es un OBJETO con sus PROPIEDADES y METODOS, lease (DOM), muchos solo lectura y etc etc.

En un javascript puedes ENCAPSULAR un objeto literal o una CLASE.

Ahora a tu pregunta |||felix||| puedes encapsuar como dices
for example

algo.js
Código PHP:
var algo=function()
{
    
this.html="<div>blabla </div>";
    
this.div=function(txt)
    {
       var 
a=document.createElement("div");
       
a.innerHTML=txt;
       return 
a;
    }
    
this.engine=function()
    {
        return 
this.html;
    }
}
algo.prototype={
     
more:function()
     {
        
//blabla
     
},
     
other:17281728

y en tu html
Código HTML:
<html>
<head>
<script src="algo.js" type="text/javascript"></script>
<script type="text/javascript">
var a=new algo();
document.body.innerHTML=a.engine();
document.body.appendChild(a.div("aloja"));
</script>

</head>
<body onload="creabla();">
</body>
</html> 
y asi sucesiamente..... tienes html en un JS y vas embediendo en tu documento.

connection closed.
__________________

Maborak Technologies