---
schema_version: "1"
id: 742a02332b0d29ae13e52ed8aaef8e9691078ab602d36345d611f3491470c045
title: setAnchor(anchor)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_System_PageReference_setAnchor.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_setAnchor.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: c455f64be1fc2064c2e86389ece4cbde25d65f813c3fd0f0a0ef4dfe8937a304
description: Sets the URL’s anchor reference to the specified string.
---
# setAnchor(anchor)

Sets the URL’s anchor reference to the specified string.

## Signature

public System.PageReference setAnchor(String anchor)

## Parameters

- **anchor**: 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.")

## Return Value

Type: [System.PageReference](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_system_pagereference.htm "A PageReference is a reference to an instantiation of a page. Among other attributes, PageReferences consist of a URL and a set of query parameter names and values.")