535
Views
6
Comments
Solved
Adding Java script to a page to refresh it
Question
Hi guys.

I have this script 
<script type="text/javascript">
    setTimeout(function () { 
      location.reload();
    }, 3000);
</script>
I would like to add it to a page hoping that it will refresh it every 3 seconds. Where exactly should I inster this script for it be enabled?

Thanks,

Jean-Pierre



2016-04-21 20-09-55
J.
 
MVP
Solution
just place it on the screen as an expression (and escape content to no)

UserImage.jpg
Jean-Pierre Brits
Thanks.

I have a script that refreshes a whole page. How can I refresh a spesifc web block?

Thank you.
2016-04-21 20-09-55
J.
 
MVP
instead of reload, use the fakenotifymessage-width and it's javascript-method.

then in the screenaction, you refresh the webblock.

or you can checkout the lightweight-ajax refresh component in the forge...

UserImage.jpg
Jean-Pierre Brits
I'm not sure what you mean here.

Should it look like this:

<script type="text/javascript">
    setTimeout(function () { 
      location.fakenotifymessage();
    }, 3000);
</script>

In the meanwhile I have found this

function RefreshResults(id)
{
    var refreshFunction = document.getElementById('RefreshGuardsContainer.Id').onclick;
    refreshFunction();
    return false;
}
 
var intervalId = setInterval('RefreshResults()', 5000);

UserImage.jpg
Jean-Pierre Brits
The last one was recommended on another OutSystems post. One thing I'm concerned about is syntax. Please let me know if you think that might not work for any reason.
2016-04-21 20-09-55
J.
 
MVP
no, check out the fakenotifywidget (webblock) in richwidgets.

place that webblock on your screen with a name (for example 'fake' )
this will also need a onchange desitination, which will be the screen-action where you refresh the webblock.

then in the code

<script type="text/javascript">
    setTimeout(function () { 
      OsNotifyWidget('" + fake.Id + "','some dummy message or empty');
    }, 3000);
</script>

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.