Although, unless something has changed you should be opening that in a new tab already anyway.
Link targets are only supported for external web links (e.g. http://www.wix.com)..)
if you are trying to open another page from your website and have it setup like this, then it will open in the same window. $w(“#myElement”).link = “/about-me”;
Set an element to open an external web link in a new browser page when clicked
It makes no sense to set the destination of a link after it has already been clicked. That’s what you’re trying to do with that code. As GOS said, set the destination of the link in the onReady handler (it could be some other event also - but it can’t be the click event of the button in question). Essentially just copy and paste the two lines you already have and place them into the onReady handler that exists by default for every new page you create.
One thing I just discovered is that if you have an onClick handler for the button, it takes precedence over any .link and .target specification you may make in your onReady handler. I have a page with a link that does two different things depending on whether you are an admin or a regular member of the website. Because of this precedence behavior I can’t reuse the button to do two different things. Instead, I must create a second button that sits on top of the first one and I show/hide the appropriate one depending on who is logged in.
Bottom line, Claudio you should detach your button174_click(event) handler from the button otherwise it won’t work!
i think you have the precedence thing right but not the idea that one button can’t do different things. You’d either set the link property or add an onClick handler but when you do this you can determine if the current user is privileged and set the appropriate value/behaviour.
@lee1 You would think so but there is no target option for wixLocation.to(). If you want one of your options to open a new tab, then you need to use my approach. Frankly Wix should just do the right thing and expose a target option but they’ve convinced themselves that this is the way it should be .