Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

116
Visualizações
Change element to an iFrame onclick

So, I created this:

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

Now I want a js function thats assigned to the onclick button function "schach()". The function should change the "box" element on click to an iframe element with the url "schach.coach".

I tried to write the function on my own, but the variable doesnt work:

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"
     }

I am sure something's wrong with my content variable or am I even using the wrong function? Please help, I am a beginner and hungry to learn.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It looks like you are assigning a string to the box instead of the actual content of the variable. Try this line instead:

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

Notice that I have removed the double quotes from the word "content"

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda