# How to open a wixLocation.to(url) in a new tab/window

**URL:** <https://forum.wixstudio.com/t/how-to-open-a-wixlocation-to-url-in-a-new-tab-window/2266>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [February 3, 2021, 10:09pm UTC](https://forum.wixstudio.com/t/how-to-open-a-wixlocation-to-url-in-a-new-tab-window/2266 "2021-02-03T22:09:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kirigiananozu](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/kirigiananozu/32/26551_2.png) [@kirigiananozu](https://forum.wixstudio.com/u/kirigiananozu)\
**Post date:** [February 3, 2021, 10:09pm UTC](https://forum.wixstudio.com/t/how-to-open-a-wixlocation-to-url-in-a-new-tab-window/2266/1 "2021-02-03T22:09:05Z")

</div>

I have a button that when I press it i want it to navigate to a url (for this im using [wixLocation.to("the](wixLocation.to(“the) url”) but how do I have it open in a new tab. Subsequent code runs after this navigation to “the url” but cannot run if “the url” is opened in the current tab.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [February 3, 2021, 10:23pm UTC](https://forum.wixstudio.com/t/how-to-open-a-wixlocation-to-url-in-a-new-tab-window/2266/2 "2021-02-03T22:23:40Z")

</div>

[https://russian-dima.wixsite.com/meinewebsite/website-navigation](https://russian-dima.wixsite.com/meinewebsite/website-navigation)

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [February 3, 2021, 11:01pm UTC](https://forum.wixstudio.com/t/how-to-open-a-wixlocation-to-url-in-a-new-tab-window/2266/3 "2021-02-03T23:01:47Z")

</div>

You **cannot**.  
You can only use target “\_blank” with links.  
If you need to open a new window without having a linked button or a linked text, you’ll have to do it using custom element and window.open() method.

---

<div class="post-metadata">

**Author:** ![mvveiga](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mvveiga/32/122599_2.png) [@mvveiga](https://forum.wixstudio.com/u/mvveiga)\
**Post date:** [February 3, 2021, 11:55pm UTC](https://forum.wixstudio.com/t/how-to-open-a-wixlocation-to-url-in-a-new-tab-window/2266/4 "2021-02-03T23:55:54Z")

</div>

Try set the button.link to the new url full format ("http://…) and the button.target = ‘\_blank’.

---

<div class="post-metadata">

**Author:** ![marlowe-shaeffer](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/marlowe-shaeffer/32/669_2.png) [@marlowe-shaeffer](https://forum.wixstudio.com/u/marlowe-shaeffer)\
**Post date:** [February 4, 2021, 12:11am UTC](https://forum.wixstudio.com/t/how-to-open-a-wixlocation-to-url-in-a-new-tab-window/2266/5 "2021-02-04T00:11:25Z")

</div>

This example should help you get started: [https://www.wix.com/velo/forum/tips-tutorials-examples/opening-a-url-in-a-new-tab-while-running-additional-code](https://www.wix.com/velo/forum/tips-tutorials-examples/opening-a-url-in-a-new-tab-while-running-additional-code)

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [February 4, 2021, 11:06am UTC](https://forum.wixstudio.com/t/how-to-open-a-wixlocation-to-url-in-a-new-tab-window/2266/6 "2021-02-04T11:06:22Z")

</div>

+keep in mind that if it is not a reaction for direct actions (click), some browsers (such as Firefox) will block it.

---

<div class="post-metadata">

**Author:** ![Rob](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rob/32/84134_2.png) [@Rob](https://forum.wixstudio.com/u/Rob)\
**Post date:** [July 8, 2025, 7:10pm UTC](https://forum.wixstudio.com/t/how-to-open-a-wixlocation-to-url-in-a-new-tab-window/2266/7 "2025-07-08T19:10:11Z")

</div>

You can do this as shown within the Velo documentation; [Link | Velo](https://dev.wix.com/docs/velo/velo-only-apis/$w/button/link)

```javascript
$w("#myElement").link = "http://wix.com";
$w("#myElement").target = "_blank";

```
