function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Board salesforceBoard salesforce 

Javascript Code to Refresh Detail page Automatically for 5 sec

Hi All,

Please help me out for JAVASCRIPT code which should be appended in Visualforce page that automatically refreshes for 5 secs.
after a record is created then it has to refresh automatically after 5 secs .

Thanks ,
Ram
Jasveer SinghJasveer Singh
Hi Board Salesforce
                             use apex's standard function instead of 3rd party.

use <apex:actionPoller> visualforce tag.
link is below......
https://mobilytejs-dev-ed.my.salesforce.com/apexpages/apexcomponents.apexp (https://mobilytejs-dev-ed.my.salesforce.com/apexpages/apexcomponents.apexp" target="_blank)


mark solved if useful for you.

Thanks & Regards
Jasveer Singh
Jasveer SinghJasveer Singh
<!-- Page --> 
<apex:page controller="exampleCon">
<apex:form> 
<apex:outputText value="Watch this counter: {!count}" id="counter"/> 
<apex:actionPoller action="{!incrementCounter}" reRender="counter" interval="15"/> 
</apex:form>
</apex:page>

/*** Controller: ***/ 

public class exampleCon { 
Integer count = 0;
public PageReference incrementCounter() { 
count++; 
return null;

public Integer getCount() 
{
return count;

}
SandhyaSandhya (Salesforce Developers) 
Hi,

Please add below code in your visual force page.
<script type="text/javascript">    
    setInterval(page_refresh, 5*60000); //NOTE: period is passed in milliseconds
</script>
For more information please refer below link

http://stackoverflow.com/questions/4644027/how-to-automatically-reload-a-page-after-a-given-period-of-inactivity


Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya



 
Board salesforceBoard salesforce
Hi Jasveer and Sandhya,
Thanks for the response.
Here the issue is that is the standard controller i need to get the current id and auto refresh the page in VF Using Javascript 
Jasveer,its not about <apex:actiopoller>
Want to get current Account id and refresh the VF in 5 Sec

Thanks ,
Ram