browserLocale( )


Gets the locale of the site visitor's browser.

A locale, also known as an IETF language tag, is an abbreviated code that defines the language, country, and other aspects of the site visitor's browser, such as number format and date format.

Some common locales include:

  • "en-US": English, United States
  • "en-GB": English, British
  • "es-ES": Spanish, Spain
  • "de-DE": German, Germany
  • "ja-JP": Japanese, Japan
  • "fr-CH": French, Switzerland
  • "it-IT": Italian, Italy
Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<string>
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

copyToClipboard( )


Copies text to the site visitor's clipboard.

The copyToClipboard() function copies the specified text to the site visitor's clipboard.

If the site visitor's browser does not support copying text to the clipboard programmatically, a modal popup that allows copying will be displayed. For example, when calling copyToClipboard from a Firefox or Edge browser the site visitor will see something similar to the popup shown below.

Copy To Clipboard Popup

The Promise returned by copyToClipboard() resolves when the specified text is copied to clipboard or the modal popup is closed. The Promise is rejected if a null value is passed as the toCopy parameter or if the visitor's browser blocks the modal popup from opening.

Method Declaration
Copy
Method Parameters
textstringRequired

The text to copy.

Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

formFactor( )


Gets what kind of device is being used to view the page.

Note: This property only checks the site visitor's device, and not which Studio Editor's breakpoint they are using.

The formFactor property gets one of:

  • "Desktop": When viewed in a desktop browser.
  • "Mobile": When viewed in a mobile browser.
  • "Tablet": When viewed in a tablet browser.

Important: Some tablet devices (such as iPads) are identified in this property as "Desktop".

Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<string>
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getAppPageData( )


Returns the data passed to a custom app page.

Wix passes data to custom app pages that you can use when implementing the page's business logic. Call the getAppPageData() function to retrieve the data and use it in your code. The data retrieved by this function is different for each type of custom app page. For more information, see App Page Data.

Learn more about building custom app pages.

If you call the getAppPageData() function in the code for a page that isn't a custom app page, the function returns null.

Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<object>
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getBoundingRect( )


Returns information about the window.

The getBoundingRect() function returns a Promise that resolves to an object containing information about the current window's size, the document's size, and the current scroll position.

Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<WindowSizeInfo>
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getCurrentGeolocation( )


Returns the current geolocation of the user.

The getCurrentGeolocation() function returns a Promise that resolves to an object containing the current geolocation of the user.

The getCurrentGeolocation() function has the following limitations:

  • On Chrome, the function only works on HTTPS sites.
  • On Chrome, Firefox, and Safari, the function only works if the user approves a popup. If they do not approve, the promise is rejected.
  • Run getCurrentGeolocation() with a setTimeout() in case the browser is set to not detect the locale. Adding the timeout lets you handle the unfulfilled promise.
Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<CurrentGeolocation>
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getRouterData( )


Returns the data that a router passed to the page in its response.

When you create a router and define its functionality in its router() function, you can choose to send data along with the router's response. That data is retrieved in the code of the page that was routed to using the getRouterData() function.

If you call the getRouterData() function from a non-router page or a router page that wasn't sent any data, the function returns null.

Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<object>
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

openLightbox( )


Opens a lightbox and optionally passes it the given data.

The openLightbox() function returns a Promise which is resolved when the lightbox closes. If the lightbox is closed programmatically using its close() function, and the close() function was invoked with a data parameter, then the Promise resolves to that data object.

If you send a data object to the lightbox, use the getContext() function in the lightbox's code to access the received data.

To pass data to the lightbox that is opened, you must open the lightbox programmatically using the openLightbox() function. If the lightbox is opened automatically when the page loads or by a link from a page element, data will not be passed to the lightbox. Therefore, if you want to pass data to the lightbox, make sure Automatically display lightbox on pages is set to No in the Lightbox Settings panel in the Editor and don't set any element's link to open the lightbox. Instead, create your own method for opening the lightbox programmatically. For example, you can add a button with an onClick event handler that calls the openLightbox() function.

To pass data back to the page that opened the lightbox, you must close the lightbox programmatically using the close() function. If the lightbox is closed by the site visitor clicking the 'X' icon, close button, or lightbox overlay, data will not be passed back the the page that opened the lightbox. Therefore, if you want to make sure data is passed back to the page that opened the lightbox, disable all of the methods mentioned above and create your own method for closing the lightbox programmatically. For example, you can add a button with an onClick event handler that calls the close() function.

Notes: Use the name of the lightbox and not the lightbox's ID when calling openLightbox(). You can find the lightbox's name by selecting the lightbox and clicking the settings button.

Only call openLightBox after the onReady event has fired.

Method Declaration
Copy
Method Parameters
namestringRequired

The name of the lightbox to open.


dataData

The data to pass to the lightbox.

Returns
Return Type:Promise<object>
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

openModal( )


Opens a modal window that displays the specified web page.

A modal window displays the page specified by the url property over your current page. Unlike a lightbox, which is opened using the openLightbox() function, the window opened by openModal() is not part of your site structure.

Only one modal window can be open at any given time. Therefore, opening a modal window closes an already open modal window if there is one.

Note: The specified url must be an HTTPS URL.

Method Declaration
Copy
Method Parameters
urlstringRequired

The URL of the page to show in the modal window.


optionsOpenModalOptionsRequired

The options used for the modal window.

Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

postMessage( )


Sends a message to the page's parent.

If a page is embedded within another site, using an HtmlComponent on a Wix site or an iframe on a non-Wix site, you can use the postMessage() function to send a message from the inner site to the outer site.

When the parent site is a Wix site, use the onMessage() function to receive the message on the parent page.

When the parent site is a non-Wix site, use the page's window.onMessage event handler to read the data property of the received MessageEvent to receive the message on the parent page.

Method Declaration
Copy
Method Parameters
messageMessageRequired

The message to send.


targetstring

The target to send the message to. Must be "parent" or omitted. Defaults to "parent".

Returns
Return Type:Promise<object>
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

referrer( )


Gets the HTTP referrer header field.

The referrer is the address of the previous web page that the user was on before arriving at the current page, typically by clicking a link.

Note: When visitors move from page to page within your site, the referrer property does not contain the address of the page the visitor came from. This is because Wix sites are built as single page applications. To get the previous page a visitor was visiting within your site, you can use storage to store the visitor's current page and retrieve the visitor's previous page.

Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<string>
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

scrollBy( )


Scrolls the page by a given number of pixels.

The scrollBy() function returns a Promise that resolves when the current page has been scrolled by the given number of pixels,

The x and y parameters determine the number of horizontal and vertical pixels to scroll the current page. Negative numbers scroll up or to the left and positive numbers scroll down or to the right.

Method Declaration
Copy
Method Parameters
xnumberRequired

The horizontal offset, in pixels, to scroll by.


ynumberRequired

The vertical offset, in pixels, to scroll by.

Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

scrollTo( )


Scrolls the page to a specific location on the page.

The scrollTo() function returns a Promise that resolves when the current page has been scrolled to a given location on the page.

The x and y parameters determine the top-left pixel that is displayed on screen after the scroll.

Tip: To get the coordinates for scrolling, display the Wix Editor Toolbar. In the Editor, move the cursor to the top-left pixel where you want the page to scroll to. The X and Y axis Position values show the coordinates.

To scroll to a specific element on the page, see the $w.Node scrollTo() function.

Use the options parameter to specify the options to use when scrolling.

Method Declaration
Copy
Method Parameters
xnumberRequired

The horizontal position, in pixels, to scroll to.


ynumberRequired

The vertical position, in pixels, to scroll to.


optionsScrollToOptions

Scrolling options.

Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

trackEvent( )


Sends a tracking event to external analytics tools.

The trackEvent() function sends an event to analytics tools connected to your site. It can send events to Google Analytics, Facebook Pixel or analytics tools set up with the Google Tag Manager.

Learn more about:

Note: The trackEvent() function only runs on published versions of your site. It doesn't work when previewing your site.

The trackEvent() function lets you track both standard and custom events.

The following standard events are supported:

Standard EventDescriptionUsed By
AddPaymentInfoWhen a site visitor saves payment information.Google Analytics, Facebook Pixel
AddProductImpressionWhen a site visitor views a product.Google Analytics
AddToCartWhen a site visitor adds a product to the shopping cart.Google Analytics, Facebook Pixel
CheckoutStepWhen a site visitor completes a checkout step.Google Analytics
ClickProductWhen a site visitor clicks on a product.Google Analytics
CompleteRegistrationWhen a site visitor completes the registration. Note: The CompleteRegistration event doesn't take any parameters.Facebook Pixel
InitiateCheckoutWhen a site visitor starts the checkout process.Google Analytics, Facebook Pixel
LeadWhen a site visitor subscribes to a newsletter or submits a contact form.Google Analytics, Facebook Pixel
PurchaseWhen the customer successfully completes the checkout process.Google Analytics, Facebook Pixel
RemoveFromCartWhen a site visitor removes a product from the shopping cart.Google Analytics
ScheduleWhen a site visitor schedules a meeting or makes an appointment. Note: The Schedule event doesn't take any parameters.Facebook Pixel
StartPaymentWhen a site visitor starts the payment process.Google Analytics
ViewContentWhen a site visitor views a key page, for example the product page.Google Analytics, Facebook Pixel
Method Declaration
Copy
Method Parameters
eventNamestringRequired

Event name. Applies to both standard and custom events. The following standard events are supported:

  • AddPaymentInfo
  • AddProductImpression
  • AddToCart
  • CheckoutStep
  • ClickProduct
  • CompleteRegistration
  • InitiateCheckout
  • Lead
  • Purchase
  • RemoveFromCart
  • Schedule
  • StartPayment
  • ViewContent

parametersunionRequired

The event's parameters. Note: The CompleteRegistration and Schedule events don't take any parameters.

Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

viewMode( )


Gets which mode the site is currently being viewed in.

The viewMode property gets either:

  • "Preview": When previewing the site using the Preview button in the editor.
  • "Site": When viewing the published site.
  • "Editor": When viewing a Wix Blocks built widget in the editor.
Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<string>
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?