Find your content:

Search form

You are here

How to display the browser Current URL in Visualforce Page

 
Share

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.


Attribution to: mylife525

Possible Suggestion/Solution #1

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}"/>

Attribution to: Matt Lacey

Possible Suggestion/Solution #2

If you're using a Controller, you can use the System.URL class to grab the base URL

Public String baseURL =   URL.getSalesforceBaseUrl().toExternalForm();

You can then bind apex:outputText to this controller variable.


Attribution to: techtrekker
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4683

My Block Status

My Block Content