How to make "Field Type 'URL'" from database open in same window

I have dynamic pages and one of the buttons is linked to the “URL” field type of my database collection. The link works fine from the dynamic page only it opens in a new window. Is there any way to make it open in the same window?

You can use the target property of the Button to set the link’s behavior.

Hi Yisrael,

Thanks, but because the button links to a URL in my database collection there is no option to change the button’s properties:

@tali54657 As shown in the link that I provided, the target property is set in code:

$w("#myButton").target = "_self";

@yisrael-wix thanks but it doesn’t work…


$w("#button1").link = "https://tali377.wixsite.com/noravnew/resting-ecg/mobile-app";
$w("#button1").target = "_self";

@tali54657 You need to put that code in the page’s onReady() function. It won’t work otherwise.

$w.onReady( function() {
   $w("#button1").link = "https://tali377.wixsite.com/noravnew/resting-ecg/mobile-app";
   $w("#button1").target = "_self";
} );

@yisrael-wix yes I had it with the onReady() command, I was missing a semicolon and a closing “)”…it works now! Thank you so much for the help!!! :slight_smile:

@tali54657 Also, you really only need to set the target property in the onReady. The link property can be set elsewhere in code, according to results from queries or other logic you might have.

I’d like to do this but instead of a link opening from a button it opens from an image in a gallery.
Do i replace the “#mybutton” with the link field i.d?