Is there a way from the HTML code app to verify if the script is on a Wix site? This is how we do Google Sites.
if (typeof gadgets !== ‘undefined’ && gadgets.window) {
// Google Sites
gadgets.window.adjustHeight(data.height);
}
Is there a way from the HTML code app to verify if the script is on a Wix site? This is how we do Google Sites.
if (typeof gadgets !== ‘undefined’ && gadgets.window) {
// Google Sites
gadgets.window.adjustHeight(data.height);
}
The fact that it’s in an HtmlComponent indicates that it’s on a Wix Site.
I didnt ask that. I asked is there a piece of code that can verify if on a Wix site like $w !== ‘undefined’?
@info59086 $w can’t be used in HTML code that’s in an HtmlComponent. The Wix Code namespace ($w) is unavailable in an HtmlComponent.
What is it that you’re trying to do?
@yisrael-wix I just want to verify I am on a Wix site from the HTML code app. I gave an example of above on how to test if on a Google Site.
@info59086 Refer to the article Working with the HTML Component in Wix Code . A simple handshake with messaging will verify that the script is running on a Wix site. For more information, refer to the HtmlComponent API .
@yisrael-wix I can access a HTML componennt from the HTML code app?
@info59086 No.
The $w.HtmlComponent is based on an iFrame. This element was designed to contain vanilla HTML and it works just fine. You just can’t try to trick it by using parent, window, top, etc. Same goes with the Javascript evaluate() function. It is sandboxed and does not allow access to the DOM.
Therefore, the HtmlComponent can’t be accessed by the HTML code embedded within it.