Estoy tratando de abrir una página web en la misma pestaña/ventana al hacer clic en una imagen ampliada. Intenté _self pero no funciona. Además, estoy usando Google Sites para desarrollar un sitio web simple. Parece fácil, pero no obtengo la respuesta y no puedo resolver el problema. Adjuntando mi código.
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> * { box-sizing: border-box; } .zoom[href] { padding: 2px; transition: transform .3s; width: 150px; height: 81px; margin: 0 auto; overflow: hidden; } .zoom:hover { -ms-transform: scale(1.3); /* IE 9 */ -webkit-transform: scale(1.3); /* Safari 3-8 */ transform: scale(1.3); } ::-webkit-scrollbar { width: 0px; /* remove scrollbar space / background: transparent; / optional: just make scrollbar invisible / } / optional: show position indicator in red */ ::-webkit-scrollbar-thumb { background: #FF0000; } </style> <script type="text/javascript"> var windowObjectReference = null; // global variable function openRequestedPopup(url, windowName) { if(windowObjectReference == null || windowObjectReference.closed) { windowObjectReference = window.open(url, windowName, "_self"); } else { windowObjectReference.focus(); }; } </script> </head> <body> <div class="zoom"> <a href="https://www.google.com" onclick="openRequestedPopup(this.href, this.target); return false;"> <img src="https://via.placeholder.com/250" alt="Our Performance" styles="width:100%"> </a> </div> </body> </html>Y esto es lo que estoy esperando:
Tengo entendido que tiene la intención de abrir una ventana emergente dentro de su página cuando el usuario hace clic en ella. Esto se puede lograr de la siguiente manera:
Deberá crear un iframe como este:
<iframe id="mypopup" style="display:none;"></iframe> function openIFrame(url) { let myPopup = document.getElementById("mypopup"); mypopup.style.display = "block"; mypopup.src = url; }Algo como
onclick="openIFrame(this.href); return false;"en tu ancla.