Exposure widgets can work on Wix designed websites but it does have some nuances because Wix sandboxes our widgets inteferring with it being a smart widget.
Our widget code must be placed in the HTML iFrame/Embed found in the Wix App Market place. Add the HTML iFrame/Embed app to the page, select Code and copy widget code into it. Our widget will work just using this but continueing the steps below will help it work better.
We recommend putting the code below on the Page Code under the tab of Site or on the page that will host the widget at the bottom of the Wix designer. This will fix our Redirect and Scroll To Top functionality, but it won't fix our dynamic Height resizing of the widget.
Also the best way to remedy the disabling of our dynamic resize is to be sure to give the HTML iFrame/Embed a large height in the Wix designer otherwise a scrollbar will appear if the widget is to long in height.
// For full API documentation, including code examples, visit http://wix.to/94BuAAs import wixWindow from 'wix-window'; import wixLocation from 'wix-location'; $w.onReady(function () { let iframe = $w('#html1'); if(iframe) { if(wixLocation.query) { if(wixLocation.query.returnurl && wixLocation.query.widget) { iframe.postMessage(JSON.stringify({ returnUrl: wixLocation.query.returnurl, widget: wixLocation.query.widget })); } } iframe.onMessage((event) => { var data = JSON.parse(event.data); if(data.scrollTop) { iframe.scrollTo(0, 0); } if(data.url) { var parentUrl = wixLocation.url; if (data.url.indexOf("?") === -1) { data.url = data.url + '?'; } else { data.url = data.url + '&'; } if (parentUrl.indexOf("?") === -1) { parentUrl = parentUrl + '?'; } else { parentUrl = parentUrl + '&'; } data.url = data.url + 'referrer=' + encodeURIComponent(parentUrl + 'widget=' + data.widgetId); wixLocation.to(data.url); } }); } });
Wix Code Page
Comments
0 comments
Please sign in to leave a comment.