Solution 1 :

Here is your solution:

<head>
  <meta meta charset="utf-8" />
</head>

<body>
  <iframe name="iframe" id="iframe" src="https://google.com" style="position: absolute; height: 100%; width: 100%;"></iframe>
  <script>
    var iframe = document.getElementById("iframe");
    var index = 0;
    var urls = ['link1', 'lnk2', 'link3'];
    var interval = window.setInterval(() => {
      console.log("hi")
      if (index > urls.length) {
        index = 0;
      }
      iframe.src = urls[index];
    }, 3000);
  </script>
</body>

</html>

Problem :

Hey can someone help me with this code?
I want to switch every x seconds the iframe source but
the page doesn’t switch the iframe.

<!doctype html>
<html>
<head>
    <meta meta charset="utf-8"/>
</head>
    <body>
    <iframe name="frame" id="frame" src="" style="position: absolute; height: 100%; width: 100%;"/>
    <script type="text/javascript">
    var iframes = document.getElementById("frame").value; 
    var index = 0;
    var urls = ['link1', 'link2', 'link3'];

    var interval = window.setInterval(function(){
    if(index == urls.length){
        if(){
            index = 0;
            }
            iframes.src = urls[index];
            }
           }, 3000);
        interval();
    </script>
    </body>
</html>

Comments

Comment posted by Barmar

You’re missing

By