jueves, 28 de agosto de 2014

Tutorial Javascript parte 13 - Objeto window (screen, navigator, location, open())




En esta parte del tutorial de Javascript veremos algunas propiedades y métodos del objeto window.

El objeto screen contiene información sobre la pantalla del visitante web.

El objeto navigator contiene información sobre el navegador del visitante web.

El objeto location contiene información sobre la url actual.

El método open() permite abrir una nueva ventana, que es lo mismo, a un nuevo objeto window.

El código del capítulo lo puedes ver a continuación ...

window.js


var width = window.screen.width;
var height = window.screen.height;
window.document.write("<p>Ancho: " + width + " : " + "Alto: " + height + "</p>");


var navegador = window.navigator.userAgent;
window.document.write(navegador);

// Redirecciones
/*
window.location.href = "http://www.google.com";
*/

/*
function open_window()
{
window.open("http://www.google.com", "_blank", "width=300, height=300");
}
*/


function create_window()
{
var ventana = window.open("", "", "width=300, height=300");
ventana.document.write("<p>Hola amigos estoy abriendo una ventana</p>");
}



No hay comentarios: