JavaScript: page refresh after timeout

25 08 2012

If webpage business logic requires to refresh it after some timeout, the JavaScript function can help. If you use JSF, take a look here to see how to refresh page from Java code.

Put this code in page <head>:

<script type="text/javascript">
	function refresh (timeoutPeriod){ 
		refresh = setTimeout(function(){window.location.reload(true);},timeoutPeriod); 
	} 
</script>

and call it, for example in onclick called on command button or command link. Provide timeout parameter that is time in milliseconds, after which page will be reloaded:

onclick="refresh(2400) "

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!

Advertisements

Actions

Information

One response

25 08 2012
Refresh JSF page programmatically from JavaBean « Looks OK!

[…] so maybe better to use this JavaScript delayed reload – give it a try! Share this:Like this:LikeBe the first to like […]

Give Your feedback:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: