The Link element represents an Link Block in the Webflow Designer.

Properties

PropertyDescriptionTypeExample
idUnique identifier for the element composed of two identifiers, the component and the element.object{component: "64c813...", element: "5edf8e59-71f9..."}
typeSpecifies the type of the element.string”Link”
childrenIndicates whether the element can contain child elements.booleanfalse
customAttributesIndicates whether the element can have custom attributes.booleantrue
stylesIndicates whether the element can contain styles.booleantrue
textContentIndicates whether the element can contain text contentbooleanfalse

Methods

element.getTarget()

Get the target value of the link block element.

Syntax

1element.getTarget(): Promise<null | string | Page | AnyElement | Asset>;

Returns

Promise<null | string | Page | AnyElement | Asset>

A Promise that resolves to an the target value of the link. The target value can be a string, Page, Element, or an Asset object.

Example

1const elements = await webflow.getAllElements() // Get All Elements
2const links = elements.filter((element) => element.type === 'Link') // Filter for Link elements
3
4// Print target value of each link element
5for (const link of links) {
6 const targetValue = await link.getTarget()
7 console.log(`ID: ${link.id.element}, Target Value: ${targetValue}`)
8}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasanyanyanyany

element.setSettings(mode, target, metadata)

Apply settings for a Link Block element. Including the type of link, its value, and metadata settings.

Syntax

1element.setSettings(
2 mode: 'url' | 'page' | 'pageSection' | 'email' | 'phone' | 'attachment';
3 target: string | Page | Element | Asset;
4 metadata?: {openInNewTab?: boolean; subject?: string;}): Promise<null>

Parameters

  • Mode: enum - The type of link to set. Can be a url, email, or phone number; a link to another page or pageSection; as well as an attachment.
  • Target: string | Page | Element | Asset - The value of the link. The value type determined by the selected mode. For example, if the link mode is “attachment” the method expects an Asset object.
  • Metadata: object - Optional metadata for link settings:
    • openInNewTab: boolean - Choose to open the link in a new tab
    • subject: string - The subject line of an email link.

Returns

Promisenull

A Promise that resolves to null

Example

1// Get Selected Element
2const element = await webflow.getSelectedElement()
3
4if (element) {
5 const newLink = await element.after(webflow.elementPresets.LinkBlock) // Create new link element
6 await newLink.setSettings('url', 'https://www.webflow.com', {openInNewTab: true}) // Set link element settings
7 const targetValue = await newLink.getTarget() // Get target value
8 console.log(targetValue)
9}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canEditAntAnyCanvasAny