Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
Cambiar elemento a un iFrame onclick

Entonces, creé esto:

https://codepen.io/Blvcksquid/pen/yLpdBoO

Ahora quiero una función js asignada a la función del botón onclick "schach()". La función debe cambiar el elemento "box" al hacer clic en un elemento iframe con la url "schach.coach".

Traté de escribir la función por mi cuenta, pero la variable no funciona:

 function schach() { let content = " <iframe class="box2" src="https://schach.coach" style="border:3px #black solid"; name="myiFrame" scrolling="yes" frameborder='1' marginheight="0px" marginwidth="0px" height="450px" width="240px" allowfullscreen></iframe>" document.getElementById("box").innerHTML = "content" }

Estoy seguro de que algo está mal con mi variable de contenido o incluso estoy usando la función incorrecta. Por favor ayuda, soy un principiante y tengo muchas ganas de aprender.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Parece que está asignando una cadena al cuadro en lugar del contenido real de la variable. Pruebe esta línea en su lugar:

 document.getElementById('box').innerHTML = content;

Tenga en cuenta que he eliminado las comillas dobles de la palabra "contenido"

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!