Hello Everyone, In this tutorial, I am going to show you, how to get the URL parameter using $CurrentPage global variable in the Visualforce page. In this example, I am getting parameter in Javascript but you get URL parameter in any part of Visualforce page using this global variable.

After completing this unit, you'll able to:
  • Get URL parameter in the Visualforce page.
Let's get started,

Step 1: Open Developer ConsoleGo to File>New>Visualforce Page and create a new Visualforce Page called GetURLParameter and replace the following markup.

GetURLParameter.vfp
 <apex:page sidebar="false" showHeader="false">    
    <center>         
        <input type="button" style="margin-top:20px;" onclick="getParameterValue();" value="Click"/>
    </center>
    <script>
    function getParameterValue(){
        var AccountId = '{!$CurrentPage.parameters.Id}';
        alert(AccountId);
    }
    </script>
 </apex:page>
In the above example replace "Id" parameter name with any that you want to get through this global variable.

Step 2: Preview the page to check your example.

Output:
See also:

Conclusion:
Hope you like this tutorial, for any query or suggestions please feel free to comment.
Thank you.