|
DOCUMENT
Objeto dependiente de window, es quien contiene las propiedades para trabajar con el documento y su contenido, es decir, la página web. Sus métodos pueden ser usados también por window. Y estos son con los que normalmente se trabaja.
|
METODO
|
DESCRIPCION
|
SINTAXIS
|
|
write
|
Escribe en el documento.
|
document.write(dato);
|
|
writeln
|
Escribe y salta de línea.
|
document.writeln(dato);
|
|
alinkColor
|
Color de enlace (sin usar).
|
document.alinkColor=”color”;
|
|
linkColor
|
Color de enlace (activo).
|
document.linkColor=”color”;
|
|
vlinkColor
|
Color de enlace (usado).
|
document.vlinkColor=”color”;
|
|
bgColor
|
Color de fondo.
|
document.bgColor=”color”;
|
|
fgColor
|
Color del texto.
|
document.fgColor=”color”;
|
|
referrer
|
Url del documento anterior.
|
var=document.referrer;
|
|
location
|
Url del documento actual.
|
var=document.location;
|
|
lastModified
|
Fecha modificación.
|
var=document.lastModified;
|
EJEMPLO
1
<html>
<head>
<script>
function fondo(colores){document.bgColor=colores;}
function texto(colores){document.fgColor=colores;}
</script>
</head>
<body>
COLOR DEL FONDO <br>
BLANCO<input type="radio" name="F" onClick=fondo("white");>
<br>
ROJO<input type="radio" name="F" onClick=fondo("red");>
<br>
AZUL<input type="radio" name="F" onClick=fondo("blue");>
<br>
<br>
COLOR DEL TEXTO
NEGRO<input type="radio" name="T" onClick=texto("black");>
<br>
GRIS<input type="radio" name="T" onClick=texto("gray");>
<br>
VERDE<input type="radio" name="T" onClick=texto("green");>
</body>
</html>
EJEMPLO 2
<html>
<head>
<script>
var v1;
function ver()
{
var fecha;
var urlantes;
var urlactual;
fecha=v1.document.lastModified;
urlantes=v1.document.referrer;
urlactual=v1.document.location;
v1.document.writeln("Creada en " +fecha);
v1.document.writeln("Dirección " +urlactual);
v1.document.write("Url anterior " +urlantes);
}
function abre()
{
v1=window.open("ab.htm","v","status=yes resizable=yes);
}
</script>
</head>
<body onLoad=crea();>
<input type="button" value="Info. Pag" onClick=ver();>
</body>
</html>
HISTORY
Objeto derivado de window, contiene todas las direcciones que se han ido visitando durante la sesión actual. Al ser un objeto derivado de window, este también puede utilizar sus métodos. Tiene 3 métodos:
|
METODO
|
DESCRIPCIÓN
|
SINTAXIS
|
|
back()
|
Vuelve a la página anterior.
|
window.history.back();
|
|
forward()
|
Nos lleva a la página siguiente.
|
window.history.forward();
|
|
go(valor)
|
Van donde le indique el número. Este
puede ser:
|
-1 como back.
|
window.history.go(valor);
|
| |
|
num lleva a pag X
|
|
| |
|
1 como forward
|
|
EJEMPLO
<html>
<head>
<script>
function pasa(valor)
{
window.history.go(valor);
}
</script>
</head>
<body>
<input type="button" value="Atrás" onClick=pasa(-1);>
<br>
<input type="button" value="Adenlant" onClick=pasa(1);>
<br>
<a href="ab.htm">ir a la pagina AB</a>
</body>
</html>
CONTINUAR
>
|