Search.../

link

Sets or gets the dashboard text button's link.

Description

When the dashboard text button is clicked, the browser navigates to the link location.

You can set link to any of the following:

  • /localPageURL: another page on your site
  • /: your site's home page
  • http(s)://<url>: an external web address
  • wix:document://<location>: a document stored in the Media Manager
  • mailto:<email-address>?subject=<subject>: an email
  • tel:<phone number>: a phone number

The link property attempts to properly encode the URL value that you set. For example, .../some page is encoded to .../some%20page. However, some URLs do not have one unambiguous encoding. In those cases it is up to you to encode the URL to reflect your intentions. Because of these situations, it is a best practice to always encode URLs before you set them as the value of the link property. Regardless of how you set the link property, when you get its value, it returns an encoded URL.

Note that Wix URLs do not contain spaces. A page which has spaces in its name has its spaces replaced with dashes (-). Similarly, a dynamic page URL which contains the value of a field in your collection with spaces has its spaces replaced with dashes (-).

Note: Make sure to set your button link before running (and not inside) the onClick() event handler.

Type:

stringRead & Write

Related Content:

Was this helpful?

Get the URL a dashboard text button navigates to

Copy Code
1let link = $w('#myElement').link; // https://wix.com
Set dashboard text button to open your site home page

Copy Code
1$w('#myElement').link = "/";
Set the dashboard text button to open an external web link in a new browser page when clicked

Copy Code
1$w('#myElement').link = "http://wix.com";
2$w('#myElement').target = "_blank";
Set the dashboard text button to open a document

Copy Code
1$w('#myElement').link = "wix:document://v1/9bec_52fb06ea/filename.xls";
Set the dashboard text button to open a new email window

Copy Code
1$w('#myElement').link = "mailto:user@example.com?subject=Some%20Topic";
Set the dashboard text button to make a phone call when clicked

Copy Code
1$w('#myElement').link = "tel:+1-555-555-5555";
Disable the dashboard text button's target

Copy Code
1$w('#myElement').link = null; // Disable the button's link property