Using Regular JS Code - is it possible ?

How can I run simple js code like “document.querySelector()” ?
The js files in the public and backend folders don’t support this, and return that ‘document’ is undefined.
Any way around this ?

Thanks!

Any one ?

Hi,

Welcome to WixCode. Glad to have you aboard.

WixCode understands all of Javascript, except for anything that accesses the DOM. Therefore, document is undefined in WixCode.

This keeps the user from inadvertently “breaking” something. I myself tried to hack things from the code, from an iFrame, and in my dreams, but WixCode wasn’t having any of it.

Accessing document elements such as div, span, button, etc is off-limits. The way to access elements on the page is only through $w. Read the $w API reference to see what is possible (a whole lot is possible).

One small exception is the $w.HtmlComponent (which 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.

Good luck and have fun,.

Yisrael

Hi, I know this is an old topic but I am new to six and using a free version to see if I can do the things I need to do with it.

Is this true of the paid version?
Also what about css, does the paid version allow for you to add your own custom css files to affect the mix DOM ?

I like what I am seeing so far but I am hoping these limitations are only on the free versions and there is an advance user level in the paid where you can be trusted to know what you are doing and be responsible for breaking things.?