Created
June 12, 2020 21:48
-
-
Save parzibyte/273248e896133782381244802c08a797 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Programado por Luis Cabrera Benito | |
____ _____ _ _ _ | |
| _ \ | __ \ (_) | | | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___ | |
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \ | |
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/ | |
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___| | |
__/ | __/ | | |
|___/ |___/ | |
Blog: https://parzibyte.me/blog | |
Ayuda: https://parzibyte.me/blog/contrataciones-ayuda/ | |
Contacto: https://parzibyte.me/blog/contacto/ | |
--> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Ventana padre</title> | |
<link href="style.css" rel="stylesheet" type="text/css" /> | |
</head> | |
<body> | |
<br> | |
<button id="btnAbrir">Abrir ventana</button> | |
<br><br> | |
<p>Si la ventana está abierta...</p> | |
<input type="text" id="mensaje" placeholder="Mensaje"> | |
<button id="btnEnviarMensaje">Enviar mensaje</button> | |
<p id="mensajeRecibido">Aquí aparecerá el mensaje recibido</p> | |
<script src="padre.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Programado por Luis Cabrera Benito | |
____ _____ _ _ _ | |
| _ \ | __ \ (_) | | | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___ | |
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \ | |
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/ | |
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___| | |
__/ | __/ | | |
|___/ |___/ | |
Blog: https://parzibyte.me/blog | |
Ayuda: https://parzibyte.me/blog/contrataciones-ayuda/ | |
Contacto: https://parzibyte.me/blog/contacto/ | |
*/ | |
const $btnAbrir = document.querySelector("#btnAbrir"), | |
$mensaje = document.querySelector("#mensaje"), | |
$btnEnviarMensaje = document.querySelector("#btnEnviarMensaje"), | |
$mensajeRecibido = document.querySelector("#mensajeRecibido"); | |
let ventana; | |
$btnAbrir.addEventListener("click", () => { | |
ventana = window.open("otra_ventana.html"); | |
}); | |
$btnEnviarMensaje.addEventListener("click", () => { | |
let mensaje = $mensaje.value; | |
if (!mensaje) { | |
return; | |
} | |
if (ventana) { | |
ventana.establecerMensaje(mensaje); | |
} | |
}); | |
// Llamada desde la hija | |
function establecerMensaje(mensaje) { | |
$mensajeRecibido.textContent = mensaje; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment