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
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
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.
The text to copy.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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".
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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
.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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:
getCurrentGeolocation()
with a setTimeout()
in case the browser is set to not detect the locale. Adding the timeout lets you handle the unfulfilled promise.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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
.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
The name of the lightbox to open.
The data to pass to the lightbox.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
The URL of the page to show in the modal window.
The options used for the modal window.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
The message to send.
The target to send the message to. Must be "parent"
or omitted. Defaults to "parent"
.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
The horizontal offset, in pixels, to scroll by.
The vertical offset, in pixels, to scroll by.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
The horizontal position, in pixels, to scroll to.
The vertical position, in pixels, to scroll to.
Scrolling options.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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 Event | Description | Used By |
---|---|---|
AddPaymentInfo | When a site visitor saves payment information. | Google Analytics , Facebook Pixel |
AddProductImpression | When a site visitor views a product. | Google Analytics |
AddToCart | When a site visitor adds a product to the shopping cart. | Google Analytics , Facebook Pixel |
CheckoutStep | When a site visitor completes a checkout step. | Google Analytics |
ClickProduct | When a site visitor clicks on a product. | Google Analytics |
CompleteRegistration | When a site visitor completes the registration. Note: The CompleteRegistration event doesn't take any parameters. | Facebook Pixel |
InitiateCheckout | When a site visitor starts the checkout process. | Google Analytics , Facebook Pixel |
Lead | When a site visitor subscribes to a newsletter or submits a contact form. | Google Analytics , Facebook Pixel |
Purchase | When the customer successfully completes the checkout process. | Google Analytics , Facebook Pixel |
RemoveFromCart | When a site visitor removes a product from the shopping cart. | Google Analytics |
Schedule | When a site visitor schedules a meeting or makes an appointment. Note: The Schedule event doesn't take any parameters. | Facebook Pixel |
StartPayment | When a site visitor starts the payment process. | Google Analytics |
ViewContent | When a site visitor views a key page, for example the product page. | Google Analytics , Facebook Pixel |
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
The event's parameters. Note: The CompleteRegistration
and Schedule
events don't take any parameters.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.