[SalesForce] How to display the browser Current URL in Visualforce Page

i have created VF page and shown that page in home components sidebar. Now my requirement is to show the browser current URL address on Sidebar component VF page.

Now its showing current VF page URL like: https://c.ap1.visual.force.com/apex/geturl?core.apexpages.devmode.url=1

But i want to the browser current address in VF Page like : https://ap1.salesforce.com/001/o

Any one please help me to over come this problem.

Best Answer

If your page is using a controller or extension (if it's not, just create an extension) then you should be able to get the URL you're after using the referer header for the Visualforce page.

Use the following method to get the URL:

public String getReferer()
{
    return ApexPages.currentPage().getHeaders().get('referer');
}

Then you can just get this in your page using:

<apex:outputText value="{!Referer}"/>
Related Topic