---
schema_version: "1"
id: 3e01aecc82bb8aae94354d3afc743a0beb636883f39e477e97e3c50c248872ba
title: getAnchor()
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_System_PageReference_getAnchor.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getAnchor.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 368c953e1411fcd359533329ce13e73be462461044a614a8d5ff71afefd39c26
description: Returns the name of the anchor referenced in the page’s URL. That is, the part of the URL after the hashtag (#).
---
# getAnchor()

Returns the name of the anchor referenced in the page’s URL. That is, the part of the URL after the hashtag (#).

## Signature

public String getAnchor()

## Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

![Note](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note.png)

#### Note

Instances of PageReference returned by ApexPages.currentPage() have a null anchor attribute, because URL fragments are not sent to the Salesforce server during a request.