Refresh an iframe every 5 sec

Hello,

Please help me add a code to the embedded iframe so that it refreshes every 5 seconds.
I am new to web development and would appreciate your response.
I searched a lot but nothing worked for me.
N.B. I don’t want to refresh the whole page.
Thank you

Hi,

Here’s a simple code example that should work for you:

<!doctype html>
<html>
<head>
<script type="text/javascript">
  let x = 0;
  function init () {
    setInterval(() => {
      x = x + 1;
      let msg = "message: " + x;
      document.getElementById('test').innerHTML = msg;
    }, 5000);
  }
</script>
</head>

<body onload="init();" style="background-color:lightgray;">
<h1>HTML Component Refresh</h1>
<p id="test">Timed message displayed here.</p>
</body>
</html>

Copy this code into an HtmlComponent, run in Preview, and then observe how the message updates every 5 seconds. You can change the code in the setInterval() function to refresh the HtmlComponent code.

Have fun!

Yisrael

Hi there, similar to the query above on embedding iframe refresh, I’d like to change the font and font size of the message, what’s the best way to input this into code? Thank you!

HTML code is not part of the Wix Code product. You can do an Internet search for changing font attributes using HTML/Javascript coding.

Take a look at the Fullscreen with HTML Component example to see an example of changing font attrubutes.