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

109
Views
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
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!