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 ,
Jasveer SinghJasveer Singh
Hi Board Salesforce
                             use apex's standard function instead of 3rd party.

use <apex:actionPoller> visualforce tag.
link is below...... (" target="_blank)

mark solved if useful for you.

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

/*** Controller: ***/ 

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

public Integer getCount() 
return count;

SandhyaSandhya (Salesforce Developers) 

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

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

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 ,