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
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.
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!