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

100
Visualizações
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 à 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