No "alert" function?

I am trying to debug using Javascript’s ‘alert’ function, but it appears to be undefined.

Is there a comprehensive list somewhere of what Javascript that Wix Code understands, and what JS it doesn’t?

Thanks

1 Like

Hey Mike,

You can use console.log(). The output appears in the Developer console and it’s not as intrusive - you don’t have to keep hitting the “dismiss” button.

Yisrael

2 Likes

Hi Mike,

To get the same effect that “JS ALERT” provides (Visual Basic MsgBox, etc). Use LightBox to design a nice popup with parsing parameters to show your custom messages. It works pretty amazing.

Best,
-Luigi

3 Likes

Well thanks for the workarounds (I already use those).

Can someone answer the original question please?

Is there a comprehensive list somewhere of what Javascript that Wix Code understands, and what JS it doesn’t?

.

Hey Mike,

Regarding your question about the limitations of Javascript in WixCode, it’s like this:

WixCode understands all of Javascript, except for anything that accesses the DOM.

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.

One small exception is the $w.HtmlElement (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. I tried. :shushing_face:

I hope that helps.

Yisrael

5 Likes

Hi there, sorry for gravedigging.
Can you give a small example on how to make a lightbox dynamic and call it?

@der-barde It’s best to start a new post regarding questions.

You can look at the Example: Slot Machine (with Lightbox) . That will show you how to communicate with a Lightbox.

I love this idea, but unfortunately Wix lightboxes take too long to load for this to be a workable solution, i.e. in a situation where a user is confirming whether they should delete an item.