Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

394
Vistas
iframe no carga la página HTML Quiero realizar la operación onClick en él, pero HTML funciona por sí solo

ingrese la descripción de la imagen aquí

La pregunta que tengo es que no quiero que mis páginas HTML funcionen en el iframe, sino que solo se muestren y cuando alguien haga clic en ellas, se abrirá una nueva página.

En este momento, el iframe central de la fila superior tiene un audio y se está reproduciendo al hacer clic de manera similar en el primer iframe de la fila inferior tiene un menú desplegable que funciona, pero quiero que si alguien hace clic en cualquier lugar, debería abrir una página correspondiente

pointer-events none también está deshabilitando el evento onclick.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

En primer lugar, debe agregar algún tipo de contenedor sobre el iframe para bloquear cualquier interacción con el iframe. Además, ese contenedor debe estar vinculado a un evento de clic del mouse que lo llevará a la página que se muestra en el iframe.

Aquí hay un ejemplo de trabajo:

 // Here is an event listner to bind a click event to the container // that covers the iframe. // All it does is take you to the page that the iframe is displaying document.getElementById("cover-iframe").addEventListener('click', () => { document.location.href = 'test.html' })
 /* Set the size of this container (width, height) to change the size of the iframe */ .container { position: relative; width: 50rem; } .iframe { width: 100%; } /* This is to make the container cover the iframe */ #cover-iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0); cursor: pointer; }
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <!-- This container is to hold the iframe and the container that will cover the iframe --> <div class="container"> <!-- "test.html" can be changed to the page you want to display --> <iframe src="test.html" frameborder="1" class="iframe"></iframe> <span id="cover-iframe"></span> </div> </body> </html>

Agregué comentarios al código anterior para que se explique por sí mismo.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda