Skip to content

Commit 03e4007

Browse files
committed
v0.2.6
1 parent 924407d commit 03e4007

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

JavaScript/BOM/01_Propiedades_Eventos.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,7 @@ document.addEventListener('DOMContentLoaded', e =>{
7878
console.warn(e);
7979
});
8080

81-
82-
83-
84-
85-
86-
87-
88-
89-
90-
91-
92-
9381
// ----- EJEMPLOS SIMILARES QUE TENEMOS EN JQUERY -----
9482
// $(window).load(()=>{});
9583
// $(window).ready(()=>{});
96-
// $(window).on("load", ()=>{});
97-
84+
// $(window).on("load", ()=>{});

JavaScript/BOM/02_Metodos.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use strict'
2+
// Metodos del BOM
3+
// Estos metodos que tenemos el BOM son muy conocidos incluso ya los hemos usado y son los siguientes:
4+
5+
// window.alert("Lanza un alerta en la web");
6+
// window.confirm("Esto es un Confirm??");
7+
// window.prompt("Esto si es un Prompt");
8+
9+
// Otros Metodos
10+
// Creamos una variable para crear un referencia a la ventana que estamos abriendo
11+
let mywindow;
12+
13+
// Aqui delegamos el evento click de los botones
14+
// APLICANDO DELEGACION DE EVENTOS
15+
document.addEventListener("click", e => {
16+
console.log(e.target);
17+
18+
if(e.target.matches("#abrir-ventana")){
19+
mywindow = window.open("https://github.com/Zelechos/");
20+
21+
// Tambien funcion sin el window de la siguiente manera
22+
// open("https://github.com/Zelechos/");
23+
}
24+
25+
if(e.target.matches("#cerrar-ventana")){
26+
// Esto es para cerrar la ventana del navegador actual
27+
// window.close();
28+
29+
// y para cerrar la ventana que hemos abierto anteriormente nos traemos la referencia donde esta almacenada
30+
mywindow.close();
31+
32+
// Tambien funcion sin el window de la siguiente manera
33+
// close();
34+
}
35+
36+
if(e.target.matches("#imprimir-ventana")){
37+
// MUY IMPORTANTEN PUEDES IMPRIMIR ESTA UNA WEB O GUARDARLA EN FORMATE PDF
38+
window.print();
39+
40+
// Tambien funcion sin el window de la siguiente manera
41+
// open("https://github.com/Zelechos/");
42+
}
43+
});

JavaScript/BOM/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>BOM</title>
8-
<script src="./01_Propiedades_Eventos.js"></script>
8+
<script src="./02_Metodos.js"></script>
99
</head>
1010
<body>
1111
<h1>BOM: Browser Object Model</h1>
1212
<h3 class="subtitle">Manejo del BOM</h3>
1313

14+
<button id="abrir-ventana">Abrir Ventana</button>
15+
<button id="cerrar-ventana">Cerrar Ventana</button>
16+
<button id="imprimir-ventana">Imprimir Ventana</button>
17+
18+
1419
</body>
1520
</html>

0 commit comments

Comments
 (0)