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

Refresh VF page to SPECIFIC location on the page?


I have a LARGE VF page on Quote with multiple sections.  One of the sections (near the bottom 2/3rds of the page) renders approvals in an object.  Each approval record has a series of buttons (approve, reject, etc.).  When users click on one of these buttons, they are directed to another form to fill out the necessary information and, when complete, they return to the quote thorugh a PageReference in an Apex class.  The issue is, when returning to the quote, it automatically returns to the TOP of the quote page.  Is there a way to make them return to the approvals section of the Quote VF page when they are being directed to the QUOTE page from the Apex Class?  Any help on how to do it?


The easiest way is probably just HTML anchors.


Add an anchor tag like this just above the approvals section.

<a name="approvals"></a>

 Then in your pagereference add #approvals to the URL so that you end up with something like this



If this helped, please click Accept as Solution or give kudos by clicking on the star on the left below my name. 


This is a brilliant idea - and elegant in its simplicity!  It works completely as expected when I append the #approvals to the URL and refresh the page.  However, when I append it to the URL from a Redirect command in a class, it doesn't put the #approvals tag.  For Example:

- Just attaching the tag to the url manually and refreshing the page  <--- WORKS!!!


-Attaching it to a redirect PageReference

PageReference reassign= new PageReference('/apex/Quote_detail?id='+QtId+'#approvals');
        return reassign;    <-----DOES NOT WORK


Is the setRedirect causing an issue?

Is this a limitation in SFDC?

Any ideas how to work around?

Does the URL update correctly to match the pagereference? The URL should
end in #approvals if it is working correctly.

You may try using the reassign.setAnchor('approvals'); method instead of
putting it in the URL string, just in case the # symbol is getting encoded.

I found that the Apex code won't let me simply append the anchor on the URL, so your SetAnchor worked.


 PageReference detilpg= new PageReference('/apex/Quote_detail?id='+Qutid);
       return detilpg;



One problem, now is:  The URL appears correctly at the top of the page, but the screen is blank until I refresh it manually.  Any more ideas?


Do you have development mode turned on? I've seen that has caused some issues in the past. Beyond that, I'd have to look at all of the code, which would be difficult if it's a large page. I'm not sure why it would show a blank page.


Here's a more technical thread with a potential javascript workaround if you can't get straight HTML to work.



Thanks for all your help.  I am opening a ticket with SFDC.  It is strange that the URL is correct (with the anchor attached) - but the page is blank until refreshed manually.  But, your help is what got me this far.  I'll post a solution (if I ever get one).

Deba SenDeba Sen

I am facing this same bank page issue with anchor. I know this is old. But did you find a solution to this back then?