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

234
Views
I can't refer to a frameset frame element with javascript? What is the error in the code?

First of all, no Jquery and iframe question does NOT solve my question, please don't address to it. i don't even understand that, just started learning javascript today. I want to change the picture in the right frame by clicking to a button in my head frame I have tried using contentWindow too, it did not work. The changing picture script works for same frame, there is a problem in accessing other frames my javascript version is 1.7

index.html

<!DOCTYPE html>
<html lang="tr" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Title</title>
  </head>
    <frameset rows="30%, 70%" noresize>
      <frame id="head" name="head" src="head.html">
      <frameset cols="50%, 50% noresize">
        <frame id="left" name="left" src="left.html">
        <frame id="right" name="right" src="right.html">
    </frameset>
  <body>
    <script type="text/javascript">
      window.frames['head'].document.getElementById('button1').addEventListener('click', () => {
        window.frames['right'].document.getElementById('image1').src = ('https://www.planetware.com/wpimages/2020/04/iceland-best-waterfalls-seljalandsfoss.jpg');
      })
    </script>
  </body>
</html>

head.html

<!DOCTYPE html>
<html lang="tr" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <h1>Site Title</h1>
    <button name="button1" id="button1">Next</button>
  </body>
</html>

right.html

<!DOCTYPE html>
<html lang="tr" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <img src="https://learnenglishteens.britishcouncil.org/sites/teens/files/styles/article/public/field/image/rs930_135120665-low.jpg?itok=g5LI5W4C" alt="picture" id ="image1" name="image1">
  </body>
</html>

this is how the site looks how it looks

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!