Search.../

SDK

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:

getCacheKiller()String
JavaScript | Copy Code

Example:

var cacheKiller = Wix.Utils.getCacheKiller();
JavaScript | Copy Code

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:

getCompId()String
JavaScript | Copy Code

Example:

var compId = Wix.Utils.getCompId();
JavaScript | Copy Code

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, it will not return the real policy of the user.

Syntax:

getCurrentConsentPolicy()Object
JavaScript | Copy Code

Object Data:

{
"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.
"policy": {
"functional": false,
"analytics": false,
"advertising": false,
"dataToThirdParty": false,
"essential": true
},
"createdDate": "2020-04-03T21:00:00.000Z" //optional
}
JavaScript | Copy Code

Example:

var policyDetails = Wix.Utils.getCurrentConsentPolicy();
if (defaultPolicy.policy.dataToThirdParty) {
// For example, if true you may be allowed to share data with Facebook. (You must check with your legal team first.)
}
JavaScript | Copy Code

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:

getDeviceType()String
JavaScript | Copy Code

Example:

var deviceType = Wix.Utils.getDeviceType();
JavaScript | Copy Code

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:

getInstanceId()String
JavaScript | Copy Code

Example:

var instanceId = Wix.Utils.getInstanceId();
JavaScript | Copy Code

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:

getInstanceValue(String){\*}
JavaScript | Copy Code

Example:

// demoMode will get a value of true or false
var demoMode = Wix.Utils.getInstanceValue('demoMode');
JavaScript | Copy Code

getIpAndPort

Returns a String which represents the app IP and port.

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, Dashboard, Modal, Popup

Syntax:

getIpAndPort()String
JavaScript | Copy Code

Example:

var ipAndPort = Wix.Utils.getIpAndPort();
JavaScript | Copy Code

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:

getLocale()String
JavaScript | Copy Code

Example:

var locale = Wix.Utils.getLocale();
JavaScript | Copy Code

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:

getOrigCompId()String
JavaScript | Copy Code

Example:

var origCompId = Wix.Utils.getOrigCompId();
JavaScript | Copy Code

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:

getPermissions()String
JavaScript | Copy Code

Example:

var permissions = Wix.Utils.getPermissions();
JavaScript | Copy Code

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:

getSectionUrl(\[sectionIdentifier\], \[callback\]) 
JavaScript | Copy Code

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:

NameTypeDescription
sectionIdentifierObjectTo 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.sectionIdStringID of the page component, as specified in the Developers Center
callbackFunction(Required if you specified the sectionId) A callback function that returns the URL of the page component (the section-url query parameter).

Example:

//eComm app directs a site visitor to a thank-you page after a purchase:
var url = Wix.Utils.getSectionUrl();
Wix.Utils.getSectionUrl({sectionId: 'myStoreApp'}, function(data) {
// Use the returned value to build a URL that directs site visitors to an
// internal thank-you page after a purchase
})
JavaScript | Copy Code

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:

getSignDate()String
JavaScript | Copy Code

Example:

var date = Wix.Utils.getSignDate();
JavaScript | Copy Code

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:

getSiteOwnerId()String
JavaScript | Copy Code

Returns:

The site owner’s ID.

Example:

var siteOwnerId = Wix.Utils.getSiteOwnerId();
JavaScript | Copy Code

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:

getTarget()String
JavaScript | Copy Code

Example:

var target = Wix.Utils.getTarget();
JavaScript | Copy Code

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:

getUid()String
JavaScript | Copy Code

Example:

var uid = Wix.Utils.getUid();
JavaScript | Copy Code

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:

getViewMode()String
JavaScript | Copy Code

Example:

var viewMode = Wix.Utils.getViewMode();
JavaScript | Copy Code

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:

getWidth()Number
JavaScript | Copy Code

Example:

var width = Wix.Utils.getWidth();
JavaScript | Copy Code

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:

navigateToSection(options, onFailure)
JavaScript | Copy Code

Parameters:

NameTypeDescription
options (required)ObjectID of the page component to navigate to, as well as optional parameters for this method
options.sectionId (required)StringID of the page component, as specified in the Developers Center
options.appDefinitionIdStringIf navigating to a page component in a different app, enter that app’s ID (specified in the Developers Center)
options.queryParamsObjectQuery 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=value1m2=value2).
options.stateStringThe new app's state to push into the editor history stack
options.shouldRefreshIframeBooleanIndicates 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.noTransitionBooleanIndicates 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:

Wix.Utils.navigateToSection(
{
sectionId: "product_gallery",
noTransition: false,
queryParams: {
param1: "value",
param2: "value"
}
},
function(error){
//Handle error use-case
}
);
JavaScript | Copy Code

Note:
This method is not available from the Dashboard endpoint.

onConsentPolicyChanged

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:

onConsentPolicyChanged(callback)
JavaScript | Copy Code

Parameters:

NameTypeDescription
callbackfunctionCallback function to receive the new policy

Example:

Wix.Utils.onConsentPolicyChanged((data)=> {
console.log(data);
});
// will log something with the following structure:
{
"defaultPolicy": false,
"policy": {
"functional": false,
"analytics": false,
"advertising": false,
"dataToThirdParty": false,
"essential": true
},
"createdDate": "2020-04-03T21:00:00.000Z"
}
JavaScript | Copy Code

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:

toWixDate()String
JavaScript | Copy Code

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:

Media.getAudioUrl(relativeUri)String
JavaScript | Copy Code

Warning:
Use this method each time you access the media item, to prevent broken links.

Parameters:

NameTypeDescription
relativeUri (required)StringURI of the audio item (relative to Wix media gallery)

Returns:

A full URL pointing to the audio file hosted on Wix static servers.

Example:

var audioUrl = Wix.Utils.Media.getAudioUrl('relative_url.mp3');
JavaScript | Copy Code

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:

Media.getDocumentUrl(relativeUri)String
JavaScript | Copy Code

Warning:
Use this method each time you access the media item, to prevent broken links.

Parameters:

NameTypeDescription
relativeUri (required)StringDocument 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:

var documentUrl = Wix.Utils.Media.getDocumentUrl('relative_url.pdf');
JavaScript | Copy Code

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:

Media.getImageUrl(Image)String
JavaScript | Copy Code

Warning:
Use this method each time you access the media item, to prevent broken links.

Parameters:

NameTypeDescription
Image (required)StringItem 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:

var imageUrl = Wix.Utils.Media.getImageUrl('relative_url.jpg');
JavaScript | Copy Code

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:

Media.getResizedImageUrl(relativeUrl, width, height, \[sharpParams\])String
JavaScript | Copy Code

Warning:
Use this method each time you access the media item, to prevent broken links.

Parameters:

NameTypeDescription
relativeUrl (required)StringStatic image url provided by the media dialog 
width (required)NumberDesired image width
height (required)NumberDesired image height
sharpParams ObjectImage sharpening properties
sharpParams.quality (required)NumberJPEG quality, leave as is (75) unless image size is important for your app
sharpParams.filter (required)NumberResize filter
sharpParams.usm_r (required)NumberUnsharp mask radius 
sharpParams.usm_a (required)NumberUnsharp mask amount (percentage)
sharpParams.usm_t (required)NumberUnsharp mask threshold

Returns:

A full URL pointing to the Wix static servers of an image with the custom dimension parameters.

Example:

var resizedImageUrl = Wix.Utils.Media.getResizedImageUrl('relative_url.jpg', 500, 500);
JavaScript | Copy Code

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:

Media.getSwfUrl(relativeUri)String
JavaScript | Copy Code

Warning:
Use this method each time you access the media item, to prevent broken links.

Parameters:

NameTypeDescription
relativeUri (required)StringSwf 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:

var swfUrl = Wix.Utils.Media.getSwfUrl('relative_url.swf');
JavaScript | Copy Code

Was this helpful?