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

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

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canEditAnyAnyCanvasAny
Built with