0

Looking for some advice to get my iframe source to refresh what is in the iframe. the source is changed by the link clicked to create the iframe content.

window.setInterval(function() {

var src = document.getElementById('frame').src; document.querySelector('iframe.reload').setAttribute('src', src);

}, 3000);

<section id="schedules">
    <div class="container"> 

<script>
    window.setInterval(function() {

      var src = document.getElementById('frame').src;
      document.querySelector('iframe.reload').setAttribute('src', src);

    }, 3000);


</Script>

    <li><a href="./schedules/1_monday.html" target="frame">Monday</a></li>
    <li><a href="./schedules/2_tuesday.html" target="frame">Tuesday</a></li>
    <li><a href="./schedules/3_wednesday.html" target="frame">Wednesday</a></li>
    <li><a href="./schedules/4_thursday.html" target="frame">Thursday</a></li>
    <li><a href="./schedules/5_friday.html" target="frame">Friday</a></li>
    <li><a href="./schedules/6_saturday.html" target="frame">Saturday</a></li>
    <li><a href="./schedules/7_sunday.html" target="frame">Sunday</a></li>              

    <iframe class="reload" name="frame" id="frame" frameborder="0" width="1200" height="700"></iframe>

 </div>
</section>

scritp is refreshing to a blakc page, looking for src but im not sure how to label src of currently loaded iframe.

  • This answer should help you out! https://stackoverflow.com/questions/86428/what-s-the-best-way-to-reload-refresh-an-iframe – James Allen Aug 09 '19 at 16:02
  • @jamesallen I've seen that and still cannot get the results im looking for. – Michael Williams Aug 09 '19 at 17:38
  • There is no need for javascript here, your target is fine and should change the iframe content on click. Could you try without any javascript ? Your script basicaly says : get my iframe and set it's src to it's current src. – Alexandre Aug 09 '19 at 17:43
  • @alexandre What the goal is, it to have the iframe refresh the current link by them self. What is loaded in the iframe is dynamic content and it would be nice if it refreshed on its own in place whne it is being viewed in the Iframe. – Michael Williams Aug 09 '19 at 20:29
  • @MichaelWilliams problem is with iframes is that is has its own DOM. The way I would do an interactive thing like you want would be with ajax. With the iframe, you could make a navigation panel inside the iframe that just change the url of the iframe, that would make it that you never exit your main page and it would navigate to the url inside the iframe if I understand correctly what you want. – Alexandre Aug 09 '19 at 20:36

0 Answers0