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

162
Views
función indefinida al usar iframe

Estoy haciendo una aplicación web de navegador en javascript. El extraño problema es que cada vez que agrego una etiqueta iframe en mi html. El javascript deja de funcionar.

Mi html:

 <input type="text" id="input"> <button onclick="sean()"></button> <iframe id="outp" src="about:blank"></iframe>

Mi JS:

 function sean(){ var input = document.getElementById('input').value; var iframe = document.getElementById('outp') iframe.src= "https://"+input alert('worked'); };

Lo curioso es que tan pronto como comento la etiqueta iframe (sin siquiera modificar js), la función funciona y muestra el mensaje de alerta; de lo contrario, sigue sean que no están definidos.

Aquí hay un bolígrafo que muestra un error, si es necesario:

https://codepen.io/ShazamBolt8/pen/yLpqeXZ

Si es posible, agregue un fragmento de código de trabajo.

Gracias por adelantado :)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

 let input = document.getElementById("txt"); let btn = document.getElementById("btn"); let iframe = document.getElementById("ifr"); btn.addEventListener("click", () => { iframe.src = "https://" + input.value; alert("wo4ked"); });
 <input id="txt" type="text" > <button id="btn">GO</button> <iframe id="ifr" src="about:blank" frameborder="10"></iframe>

about 4 years ago · Santiago Trujillo 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!