Make Button Open in Same Page (not new tab)

Hello!

I’m new here. Apologies if this isn’t the correct avenue to ask for help on this.

I have a repeater that’s connected to a data set in Wix. One of the elements in my repeater is a button. I want that button to connect to a page on my website. The only option to do this is to add a URL field in the data set, then paste the URL for that page. Even when I do that, the page opens in a new tab.

From what I read, this is normal behavior, but…

  1. Is there a way to make it open within the same page instead of a new tab?

  2. And is there a more intuitive way of making that button open a new page, rather than me pasting the public link in the URL field?

Thanks in advance!

I want these to open in new pages.

This is where i have to paste to public URL manually.

1 Like
$w.onReady(() => {
    $w("#button1").target = "_self";
})

Amazing! That worked :slightly_smiling_face: Thank you! Do you happen to know if there is a more intuitive way to get those buttons to point to pages on my website besides pasting the URL in the data set?

@ariantsarraf it depends on what exactly you’re trying to do. More details about the data and the links are needed in order to answer this question.

@jonatandor35 Maybe what I’m asking for may not exist - might be a feature request.

But if I don’t connect the button to a data set, it gives me the option to quickly choose a page that I already have created, rather than manually type in a Web Address/URL…

When I connect the button to a data set (which I want ultimately) I lose the feature/option to easily choose a page to load to. I have to copy the public HTML link and put it in the URL field of the dataset…

Hope that makes sense.

@ariantsarraf Yo’u’re using a repeater that gets its data from the database. each item should have its own link and should redirect to a different link. So it only makes sense to store the link together with the item details in your collection.
There’s an option to set the links using code instead of saving them in the database, but I don’t see the point. Maybe I don’t fully understand what exactly you’re trying to achieve.

i saw couple of tips said using :
$w.onReady(function () {
$w(“#button1”).target = “_self”;
but i only be able to open in same page for the “first click”, then if i try to open the other product it will opened in the new tab. any idea what supposed i do?

where exactly should i put these code at?
after the repeater function?

Please publish a new post and explain your use case in details.