sábado, 20 de junio de 2009

Pasar valores desde un popup

Primero para llamar una ventana como popup se puede usar el siguiente JavaScript:

function OpenDefault(url, height, width) {
var str = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,Titlebar=0,resizable=0,fullscreen=0,"
str += "height=" + height + ",innerHeight=" + height;
str += ",width=" + width + ",innerWidth=" + width;
var name = "_blank"
if (window.screen) {
var ah = screen.availHeight - 30;
var aw = screen.availWidth - 10;
var xc = (aw - width) / 2;
var yc = (ah - height) / 2;
str += ",left=" + xc + ",screenX=" + xc;
str += ",top=" + yc + ",screenY=" + yc;
}
window.open(url, name, str);

}

Luego para devolver un valor del popup a la página principal se utiliza el opener de la siguiente forma

window.opener.document.getElementById("campo").value = valorDelPopUp;

No hay comentarios:

Publicar un comentario

 
Locations of visitors to this page