Open new tab


I would like to open a new page from the button´s properties.

In HTML code this will be like this: “, ‘_blank’);”, but I don´t know how to do ir in wix.

Thank you!

1 Like


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 . Here is an example how to navigate to an about page:"/about");

This should get you going in the right direction.

Have fun,


Thank you!!

It´s its open the new url in the same page, and y would like to open it in new tab. It´s possible?

Thank you!

1 Like


As far as I know, the options of opening in the same page, new window, new tab are browser settting and that there’s really no method to code opening a URL in a new tab/window. I believe that there was at one time a standards proposal regarding this issue but so far it has not been approved.

Oh well :disappointed:

I also need to open a link in a new window.

Using the element’s:“_blank”;
would seem to be the answer for a button or image or other element.

I am using dynamically created links based upon a client clicking the email column in a table. I can use:“mailto:” + customerEmail+ “?subject=Responding to your purchase order…”);

This works great. It opens the email client, pre-filled with email address and subject, but in the same window. This forces the client to reload the database (and password screens) after sending the email.

Can I set the target property of wixLocation somehow to “_blank”?

1 Like

Hi Roger,
It is not possible to combine with target=_blank.
First of all feel free to add a feature request here .
My suggestion is to use a repeater and design it like a table. In the email column add a button element with _blank as target.

Instead of:

$w("#myElement").link = "/about-me";
$w("#myElement").target = "_blank";

We can use this to open a new tab:

import wixLocation from 'wix-location';

let BaseUrl = wixLocation.baseUrl;
let myLink = "/about-me"

$w("#myElement").link = BaseUrl + myLink;
$w("#myElement").target = "_blank";

The secret is to use http: // or https: // the URL for Google Chrome to open in a new tab when we use it: .target = “_blank”

Sorry, but this doesn’t open the link in another browser tab either, or I don’t know what I’m doing wrong :frowning: Can someone help me?

1 Like

Here’s a workaround I made using HTML frames to open a URL in a new tab from velo: