Hi,
As a preface to my answer…
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.
Now, with that in mind, what you need to do is to use wix-location . To navigate to a specific URL, use wix-location.to() . Here is an example how to navigate to an about page:
wixLocation.to("/about");
This should get you going in the right direction.
Have fun,
Yisrael