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

104
Vistas
JavaScript --- Looping through elements in webpage #2 from webpage #1

Totally new to JavaScript. As in, today.

From an .html file on my MacBook desktop, I want to open TWO webpages. The first is the file itself, say from the command line, as follows:

open ~/Desktop/first.html

The second webpage is one that I call from the first.html file:

<!DOCTYPE html>
    <head>
        <meta charset="utf-8" />
        <title>JavaScript stuff</title>
    </head>
    <body>
        <script>
            w = window.open('https://fireship.io/courses/javascript/beginner-js-where-to-run/');
            const elements = w.document.querySelectorAll('*');
            const count = elements.length;
            alert(count)
            elements.forEach((elem) => {
                console.log(elem)
            });
        </script>
    </body>
</html>

WHAT I WANT TO BE HAPPENING is that w.document.querySelectorAll('*') is getting all elements in the second webpage, meaning https://fireship.io/courses/javascript/beginner-js-where-to-run/. WHAT'S ACTUALLY HAPPENING, though, is that the elements from first.html are returning. This is confirmed by inspecting the console output of first.html.

So, my general question is --- How do I loop through the elements of one webpage from scripting that resides in another?

Any help or direction is much appreciated!

Justin

about 4 years ago · Juan Pablo Isaza
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