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

191
Views
IFRAME no carga todos los enlaces en el pedido, sino solo el último en bucle

Tengo una matriz de nodos en Drupal CMS. Necesito visitar el enlace en iframe, cambiar algunos campos, guardar e ir a otro enlace dentro de mi ciclo. El problema es: solo se carga el último enlace en iframe, cuando ejecuto el script en modo de depuración, iframe no carga los enlaces e iframe.contentWindow.document.readyState se está cargando.

Cuando uso iframe.addEventListener('load', ...) solo activa el último enlace

Entonces necesito algo como esto

 for(let i = 0; i < links.length; i++) { iframe.contentWindow.location.href = links[i] //when iframe is fully loaded and webpage is available change fields in iframe web page save changes }

Quiero ejecutar este script y ver cómo se carga, cambia y guarda cada enlace

Esto es lo que probé

 const snippetMainContainer = document.createElement('div') const snippetPageView = document.createElement('iframe') snippetPageView.id = "snippetIframe" const snippetUrl = document.createElement('input') snippetMainContainer.append(snippetUrl) snippetMainContainer.append(snippetPageView) document.querySelector('body').appendChild(snippetMainContainer) snippetPageView.setAttribute('src', `https://domen.com`) function changePage() { const url = snippetPageView.contentWindow.location.href snippetUrl.value = url } snippetPageView.addEventListener('load', () => { changePage() }) const nodeIdStr = `6001 5996 5296 5291` const nodeIdArr = nodeIdStr.split('\n') async function startEditNodes () { let nodeLink = '' for(let i = 0; i < nodeIdArr.length; i++) { nodeLink = `https://domen.com/node/${nodeIdArr[i]}/edit` snippetPageView.contentWindow.location.href = nodeLink editNode() } } async function editNode () { // console.log(`nodeLink: ${link}`) const buyNowFusepump = snippetPageView.contentWindow.document.getElementById('edit-field-product-fusepump-wrapper') const buyNowLink = snippetPageView.contentWindow.document.getElementById('edit-field-product-buy-link-wrapper') const firstTab = snippetPageView.contentWindow.document.querySelector('.horizontal-tab-button-0 a') const saveBtn = snippetPageView.contentWindow.document.getElementById('edit-submit') if(firstTab) { firstTab.click() } snippetPageView.contentWindow.scrollTo(0,600) buyNowFusepump ? await editInput(buyNowFusepump) : console.log('Fusepump absent') buyNowLink ? await editInput(buyNowFusepump) : console.log('Buy now link absent') saveBtn ? saveBtn.click() : console.log('saveBtn absent') } async function editInput(node) { const nodeInput = node.querySelector('input') nodeInput.value = nodeInput.value + 'E' } startEditNodes ()
about 4 years ago · Juan Pablo Isaza
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!