Wix.Utils
getCacheKiller
Returns a String which is the cacheKiller query parameter.
SDK Version: SDK 1.12.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Dashboard, Modal, Popup
Syntax:
1getCacheKiller() → String
Example:
1var cacheKiller = Wix.Utils.getCacheKiller();
getCompId
Returns a String which represents the component’s iframe component ID.
SDK Version: SDK 1.12.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Dashboard, Modal, Popup
Note:
Trying to use this method in the settings endpoint? To get the compId of the component that opened the settings endpoint, use getOrigCompId.
Syntax:
1getCompId() → String
Example:
1var compId = Wix.Utils.getCompId();
getCurrentConsentPolicy
Returns an object containing the user's current policy.
SDK Version: SDK 1.425.0
Display: Live Site
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Important:
Use this method in the live site only. Although it works in the Editor/Preview, and will not return the real policy of the user.
Syntax:
1getCurrentConsentPolicy() → Object
Object Data:
1{2 "defaultPolicy": false, // True = this policy is the default policy for the site as defined by the site owner. False = the user actively accepted/set this policy.3 "policy": {4 "functional": false,5 "analytics": false,6 "advertising": false,7 "dataToThirdParty": false,8 "essential": true9 },10 "createdDate": "2020-04-03T21:00:00.000Z" //optional11}
Example:
1var policyDetails = Wix.Utils.getCurrentConsentPolicy();2if (defaultPolicy.policy.dataToThirdParty) {3 // For example, if true you may be allowed to share data with Facebook. (You must check with your legal team first.)4}
getDeviceType
Returns a String which represents the current device type: Desktop or Mobile
SDK Version: SDK 1.12.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1getDeviceType() → String
Example:
1var deviceType = Wix.Utils.getDeviceType();
getInstanceId
Returns a String which represents the app instance ID.
SDK Version: SDK 1.12.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1getInstanceId() → String
Example:
1var instanceId = Wix.Utils.getInstanceId();
getInstanceValue
Returns the current value of the requested key. If the key does not exist, null is returned.
SDK Version: SDK 1.12.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1getInstanceValue(String) → {\*}
Example:
1// demoMode will get a value of true or false2var demoMode = Wix.Utils.getInstanceValue('demoMode');
getLocale
Returns a String which represents the current locale of the website or editor (en (English), es (Spanish), fr (French), it (Italian), etc.).
SDK Version: SDK 1.14.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
A locale is an abbreviated language tag that defines the user’s language, country and any special variant preference of the user interface (e.g. Number format, Date format, etc.).
Syntax:
1getLocale() → String
Example:
1var locale = Wix.Utils.getLocale();
getOrigCompId
Returns a String which represents the iframe’s component id which opened the App Settings panel.
SDK Version: SDK 1.14.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1getOrigCompId() → String
Example:
1var origCompId = Wix.Utils.getOrigCompId();
getPermissions
Returns a String which represents the user’s permissions (decoded property of the instance query parameter).
SDK Version: SDK 1.12.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1getPermissions() → String
Example:
1var permissions = Wix.Utils.getPermissions();
getSectionUrl
This method returns the URL of your page component in the live site, for example: mysite.com/my-store-app. You’ll use this URL to build the URLs for the app’s internal pages, for example: mysite.com/my-store-app/product1.
SDK Version: SDK 1.37.0+
Display: Live Site
Components: Page
Use this method if you have a page component and you’re using server-side rendering to create deep links for internal pages.
Syntax:
1getSectionUrl(\[sectionIdentifier\], \[callback\])
Important:
Use this method in the live site only. Although it works in the Editor/Preview, it returns the URL of the iframe itself – not the page URL in the site.
Parameters:
Name | Type | Description |
---|---|---|
sectionIdentifier | Object | To get the URL of a specific page component, specify its ID (as well as a callback function). If you don’t specify the ID, this method returns the URL of the current page component. |
sectionIdentifier.sectionId | String | ID of the page component, as specified in the Developers Center |
callback | Function | (Required if you specified the sectionId) A callback function that returns the URL of the page component (the section-url query parameter). |
Example:
1//eComm app directs a site visitor to a thank-you page after a purchase:2var url = Wix.Utils.getSectionUrl();3Wix.Utils.getSectionUrl({sectionId: 'myStoreApp'}, function(data) {4 // Use the returned value to build a URL that directs site visitors to an5 // internal thank-you page after a purchase6})
getSignDate
Returns a string which represents the signDate of the app instance.
SDK Version: SDK 1.13.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1getSignDate() → String
Example:
1var date = Wix.Utils.getSignDate();
getSiteOwnerId
Returns a string that represents the site owner’s ID.
SDK Version: SDK 1.52.0+
Editor Version: New Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1getSiteOwnerId() → String
Returns:
The site owner’s ID.
Example:
1var siteOwnerId = Wix.Utils.getSiteOwnerId();
getTarget
Returns a string which is the target query parameter (for the section-url). If it does not exist, returns null.
SDK Version: SDK 1.12.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Dashboard, Modal, Popup
Syntax:
1getTarget() → String
Example:
1var target = Wix.Utils.getTarget();
getUid
Returns a string which represents the user identifier.
SDK Version: SDK 1.12.0+
Editor Version: New Editor, Old Editor
Display: Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1getUid() → String
Example:
1var uid = Wix.Utils.getUid();
getViewMode
Returns a string which represents the current view mode.
SDK Version: SDK 1.12.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Modal, Popup
Syntax:
1getViewMode() → String
Example:
1var viewMode = Wix.Utils.getViewMode();
getWidth
Returns a number which represents the iframe’s width.
SDK Version: SDK 1.12.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Modal, Popup
Syntax:
1getWidth() → Number
Example:
1var width = Wix.Utils.getWidth();
navigateToSection
Navigates to your page component – either to the page component itself or to one of your app’s internal pages.
SDK Version: SDK 1.95.0+
Editor Version: New Editor
Display: Live Site, Preview
Components: Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Modal, Popup
To navigate to a widget or fixed-position widget, use Wix.navigateToComponent instead.
Syntax:
1navigateToSection(options, onFailure)
Parameters:
Name | Type | Description |
---|---|---|
options (required) | Object | ID of the page component to navigate to, as well as optional parameters for this method |
options.sectionId (required) | String | ID of the page component, as specified in the Developers Center |
options.appDefinitionId | String | If navigating to a page component in a different app, enter that app’s ID (specified in the Developers Center) |
options.queryParams | Object | Query parameters to add to the page URL when navigating to it, in key value pairs. For example: {param1:value1, param2:value2,...}. These query params are included in the iframe URL (e.g., ?param1=value1¶m2=value2). |
options.state | String | The new app's state to push into the editor history stack |
options.shouldRefreshIframe | Boolean | Indicates if the app iframe should be refreshed when navigating to the page. Default value is true. When queryParams are defined, shouldRefreshIframealways defaults to true. |
options.noTransition | Boolean | Indicates if there should be a transition when navigating to the page. Default value is false. |
onFailure (required) | Function | This will be called if the hosting site does not include the section app, or if the caller's application does not include a section |
Example:
1Wix.Utils.navigateToSection(2 {3 sectionId: "product_gallery", 4 noTransition: false, 5 queryParams: {6 param1: "value", 7 param2: "value"8 }9 }, 10 function(error){11 //Handle error use-case12 }13);
Note:
This method is not available from the Dashboard endpoint.
getOnConsentPolicyChanged
Retrieves the user's new policy.
SDK Version: SDK 1.425.0
Display: Live Site
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Important:
Use this method in the live site only. Although it may work in the Editor/Preview, it will not give you real data.
Syntax:
1getOnConsentPolicyChanged(callback)
Parameters:
Name | Type | Description |
---|---|---|
callback | function | Callback function to receive the new policy |
Example:
1Wix.Utils.getOnConsentPolicyChanged((data)=> {2 console.log(data);3});4// will log something with the following structure:5{6 "defaultPolicy": false,7 "policy": {8 "functional": false,9 "analytics": false,10 "advertising": false,11 "dataToThirdParty": false,12 "essential": true13 },14 "createdDate": "2020-04-03T21:00:00.000Z"15}
toWixDate
Converts a JavaScript Date object into the correct format, ISO 8601, used by Wix APIs when dealing with dates.
SDK Version: SDK 1.28.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1toWixDate() → String
Media.getAudioUrl
Constructs the absolute URL for an audio file in the Wix Media Manager.
SDK Version: SDK 1.17.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1Media.getAudioUrl(relativeUri) → String
Warning:
Use this method each time you access the media item, to prevent broken links.
Parameters:
Name | Type | Description |
---|---|---|
relativeUri (required) | String | URI of the audio item (relative to Wix media gallery) |
Returns:
A full URL pointing to the audio file hosted on Wix static servers.
Example:
1var audioUrl = Wix.Utils.Media.getAudioUrl('relative_url.mp3');
Media.getDocumentUrl
Constructs a URL for a media item of type document.
SDK Version: SDK 1.17.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1Media.getDocumentUrl(relativeUri) → String
Warning:
Use this method each time you access the media item, to prevent broken links.
Parameters:
Name | Type | Description |
---|---|---|
relativeUri (required) | String | Document item uri (relative to Wix media gallery) |
Returns:
A full URL pointing to the Wix static servers of a document media file with the default dimensions.
Example:
1var documentUrl = Wix.Utils.Media.getDocumentUrl('relative_url.pdf');
Media.getImageUrl
Constructs a URL for a media item of type image.
SDK Version: SDK 1.17.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
On the live site, we recommend using Media.getResizedImageUrl instead (for better performance).
Syntax:
1Media.getImageUrl(Image) → String
Warning:
Use this method each time you access the media item, to prevent broken links.
Parameters:
Name | Type | Description |
---|---|---|
Image (required) | String | Item uri (relative to Wix media gallery). |
Returns:
A full URL pointing to the Wix static servers of an image with the default dimensions – width and height.
Example:
1var imageUrl = Wix.Utils.Media.getImageUrl('relative_url.jpg');
Media.getResizedImageUrl
Constructs a URL for a media item of type image. You can change the image dimensions as well as its sharpening properties. Learn more about sharpening.
SDK Version: SDK 1.17.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1Media.getResizedImageUrl(relativeUrl, width, height, \[sharpParams\]) → String
Warning:
Use this method each time you access the media item, to prevent broken links.
Parameters:
Name | Type | Description |
---|---|---|
relativeUrl (required) | String | Static image url provided by the media dialog |
width (required) | Number | Desired image width |
height (required) | Number | Desired image height |
sharpParams | Object | Image sharpening properties |
sharpParams.quality (required) | Number | JPEG quality, leave as is (75) unless image size is important for your app |
sharpParams.filter (required) | Number | Resize filter |
sharpParams.usm_r (required) | Number | Unsharp mask radius |
sharpParams.usm_a (required) | Number | Unsharp mask amount (percentage) |
sharpParams.usm_t (required) | Number | Unsharp mask threshold |
Returns:
A full URL pointing to the Wix static servers of an image with the custom dimension parameters.
Example:
1var resizedImageUrl = Wix.Utils.Media.getResizedImageUrl('relative_url.jpg', 500, 500);
Media.getSwfUrl
Constructs a URL for a media item of type swf.
SDK Version: SDK 1.17.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Settings Panel, Settings Modal, Dashboard, Modal, Popup
Syntax:
1Media.getSwfUrl(relativeUri) → String
Warning:
Use this method each time you access the media item, to prevent broken links.
Parameters:
Name | Type | Description |
---|---|---|
relativeUri (required) | String | Swf item uri (relative to Wix media gallery) |
Returns:
A full URL pointing to the Wix static servers of a swf media file with the default dimensions.
Example:
1var swfUrl = Wix.Utils.Media.getSwfUrl('relative_url.swf');
Deprecated
getIpAndPort
Returns a String which represents the app IP and port.
SDK Version: Deprecated
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Wix Dashboard, Widget, Pinned (aka Fixed-Position) Widget, Page, Dashboard, Modal, Popup
Syntax:
1getIpAndPort() → String
Example:
1var ipAndPort = Wix.Utils.getIpAndPort();