At the window.onload() event of a standard object detail page I am storing the time value in one of its fields. I have embedded a vf page along with this detail page. At the click of a button in the embedded vf page shown,the object detail page refreshes and the window.onload event resets the value to the new time stored in the object field. Is there a way to stop the detail page from refreshing?

Just adding snippets of the code here :

    window.onload = function() 
        sforce.connection.sessionId = "{!$Api.Session_ID}";
        var aResult = sforce.connection.query("SELECT Time__c FROM card__c where Id = {!card__c.Id}");
        /*code to update the time filed on the object*/
    function abc()  
        /*Some DML Operations here*/
           <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Do Something" onclick="abc" />
  • Can you show us your code please ?
    – SF_user
    Sep 5, 2014 at 11:56
  • Hi I have added a little bit of the code to give you an idea of what I am trying to do. Whenever I click the do something button the object detail page refreshes. The onload function in the script works perfectly. Sep 5, 2014 at 12:11

2 Answers 2


You need to add return false; to your onclick function. Without that the page will reload after clicking.

Another solution is to add an rerender="none" tparameter to the command button.

So it will look like this:

<apex:commandButton value="Do Something" onclick="abc(); return false;" />

or like this:

<apex:commandButton value="Do Something" onclick="abc(); reRender="none" />

Change :

<apex:commandButton value="Do Something" onclick="abc()" />

to :

<apex:commandButton value="Do Something" onclick="abc(); return false;" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.