How can I modify all buttons to open links in a new tab?

Solved

How can I modify all buttons to open links in a new tab?

UtopiaCaffe
Tourist
5 0 1

How do I edit all buttons to redirect on a new tab?

Accepted Solution (1)

Rileymuk
Tourist
3 1 2

This is an accepted solution.

Hi @UtopiaCaffe hopes it will help you
To make all buttons on a web page redirect to a new tab when clicked, you can add the target="_blank" attribute to each button's HTML code. This attribute instructs the browser to open the link in a new tab. Here's an example of how you can modify a button's HTML code:

Before modification:

<button onclick="window.location.href='your_destination_url'">Click me</button>

After modification:

 

<button onclick="window.open('your_destination_url', '_blank')">Click me</button>

In the modified code, window.open is used with the parameters 'your_destination_url' (replace with the actual URL you want to redirect to) and '_blank' (which specifies to open the link in a new tab).

Please note that modifying HTML code might require access to the source code of the website or application. If you're using a Content Management System (CMS) or a website builder, the process may vary. Additionally, be mindful of user experience, as forcing all links to open in new tabs might not be the best practice for usability.

View solution in original post

Replies 5 (5)

Rileymuk
Tourist
3 1 2

This is an accepted solution.

Hi @UtopiaCaffe hopes it will help you
To make all buttons on a web page redirect to a new tab when clicked, you can add the target="_blank" attribute to each button's HTML code. This attribute instructs the browser to open the link in a new tab. Here's an example of how you can modify a button's HTML code:

Before modification:

<button onclick="window.location.href='your_destination_url'">Click me</button>

After modification:

 

<button onclick="window.open('your_destination_url', '_blank')">Click me</button>

In the modified code, window.open is used with the parameters 'your_destination_url' (replace with the actual URL you want to redirect to) and '_blank' (which specifies to open the link in a new tab).

Please note that modifying HTML code might require access to the source code of the website or application. If you're using a Content Management System (CMS) or a website builder, the process may vary. Additionally, be mindful of user experience, as forcing all links to open in new tabs might not be the best practice for usability.

logangelzer
Shopify Partner
21 5 9

Agree with this solution

Logan Gelzer
Founder & CEO
Logo Media
logan@logo.media
Rileymuk
Tourist
3 1 2

Thanks @logangelzer 😘
@UtopiaCaffe mark it as a best solution

UtopiaCaffe
Tourist
5 0 1

Thank you so much.

sorrycoffee22
Visitor
1 0 0

My code doesn't show this line when I find the section for my buttons. Not sure where to go from here. 

 

},
"button_QnC4rP": {
"type": "button",
"disabled": true,
"settings": {
"button_label": "Shop Here",
"button_link": "https://prima-coffee.com/equipment/technivorm/79112-techn-pp",
"button_style_secondary": false
}
}