Set Link Settings

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;}
5): Promise<null>

Parameters

ParameterTypeDescription
modeenum
'url' | 'page' | 'pageSection' | 'email' | 'phone' | 'attachment'
The type of link to set. Can be a URL, email, phone number, link to another page or page section, or an attachment.
targetstring | Page | Element | AssetThe value of the link. The value type is determined by the selected mode. For example, if the link mode is “attachment”, the method expects an Asset object.
metadataobject (optional)Optional metadata for link settings. See fields below.

metadata fields:

FieldTypeDescription
openInNewTabbooleanChoose to open the link in a new tab.
subjectstringThe subject line of an email link.

Returns

Promise<null>

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", {
7 openInNewTab: true,
8 }); // Set link element settings
9 const targetValue = await newLink.getTarget(); // Get target value
10 console.log(targetValue);
11}

Designer ability

Designer AbilityLocaleBranchWorkflowSitemode
canEditAnyAnyCanvasAny