Repeater: Open link in same window...

I have an opposite problem…
I need open link in a new tab…Lol …)))
https://www.wix.com/corvid/forum/community-discussion/how-to-open-new-tab-here?utm_source=email_mkt

@ahmedalv94 Oh how I wish I could code !!! Tried this and it doesn’t work for me as I keep getting an error message in the code in regards to wixlocation… (data) needs to be replaced by ? I’m a rookie ! Thanks

The best way to definitively determine how your link opens is by using a text or image element.

For images:

$w('#myImage').link = 'https://duck.com';
$w('#myImage').target = 'self'; //or '_blank' for new window 

For text:

const txt = $w('#myText'),
    pre = txt.html.split(txt.text)[0],
    post = txt.html.split(txt.text)[1];
txt.html = `${pre}<a href="https://duck.com" target="self">${txt.text}</a>${post}`;

@ahmedalv94 this seems to be the closest thing to a solution I’ve come across. I added that code but ran into the same problem as @hurtubisecarl . I got an error message related to the “wixLocation” portion of the code (see screen shot). Any idea on how to fix this?

Fixed!!

Repeater: Open link in same window!!

I had the same issue and finally fixed it. Your visitors will now be able to click on the button and the link loads in the same page instead of opening up a new tab. This is in reference to adding the URL link in content manager inside a column set with the URL property and connecting it to the button on the repeater.

$w(“#element1”).target = “_self”;

You have to update this code with the correct button ID, its not just pasting the default code, its also updating the “element1” to the correct button ID so that it works properly. If you just paste this code without the update it will give you the error.

Remember to set your column property in content manager to “URL” before you paste your URL link inside the field and before you do all these connections and coding.

Check out the screen shot below with some steps

Hope this helps

1 Like

Does this work in all browsers, or just in Safari @geoglobalsolutionsco ?
I have managed to get it to work in Safari, but not i Chrome. Anyone know why this happens in some browsers?

Can someone provide guidance on to force the content manager URL link to Image be opened in the same window?

I achieved this by using the following code.

$w . onReady ( function () {
$w ( “#imageX1” ). target = “_self” ;
$w ( “#imageX2” ). target = “_self” ;
$w ( “#imageX3” ). target = “_self” ;
$w ( “#imageX4” ). target = “_self” ;
});

One more issue is database image gallery does not provide URL links. Is there any possible solution?

Thank you so much, your one-line code actually solved the issue.

It works!
thank you so much, I’ve been looking for the answer for weeks. :hugs:

i can open the link in the same page but it only works in “first click”, any way to solve it?

This post is from 2018 and will be closed. Please start a new post with your question and place the relevant code you are having trouble with in a code block. You will be more likely to get someone from the community to help this way. If you believe the discussion here is relevant to your issue, you may link to this post. Thanks!