Refresh HTML every 5 secs

Hello there!
I have a code below, and I don’t know why it didn’t refresh the html every 5 secs. Actually, I embedded a site in that html (e.g. https://www.example.com ).

$w.onReady(function () {
    setInterval(function(){
        $w("#html1").src = "https://www.example.com";
    }, 5000);
})

Thank you all in advance! :blush:

1 Like

Here take a look at this one…
https://russian-dima.wixsite.com/meinewebsite/reload-website

This should be what you are looking for.

Also take a look at the advanced example here …

https://russian-dima.wixsite.com/meinewebsite/test-1

Do it like this
Inside the htmlComponenet:

<script type="text/javascript">
   window.onmessage = (event) => {
     if (event.data) {
      location.reload();
     }
   }
 </script>

In the parent page:

$w.onReady(function () {
 $w("#htmlComponent1").src="https://www.example.com";
    setInterval(function(){
        $w("#htmlComponent1").postMessage("refresh");
    }, 5000);
})

Ohh, ok. I will have to take a look at this :grin:. Thx J.D.!

Hi @jonatandor35 and @russian-dima ! Thank you very much guys for your help!

I already solved my problem. :grin: I just tried a code on my “https://www.example.com” and it works great because when I tried @jonatandor35 's code, it didn’t work on my end, and I didn’t know any html coding that’s why I haven’t yet understood the script that he suggested. By the way, I used a repeater which is shown in my html that’s why you can see a dataset in the code below. But still thank you very much guys! :blush:

$w.onReady(function () {
    setInterval(function(){
        $w("#dataset").refresh();
    }, 5000);
})