Webflow sync, pageviews & more.
NEW
Answers

How can I disable the target=blank code in Webflow's link properties for an image that links to email, so that it doesn't open a separate tab with ?subject=(subject) in the browser?

To disable the `target="_blank"` code in Webflow for an image that links to an email, you can follow these steps:

1. Select the image element on your Webflow canvas.
2. In the right-hand panel, click on the "Settings" tab.
3. Scroll down to the "Link Settings" section and click on the dropdown menu next to "Open link in new tab".
4. Choose the option "Current tab" instead of "New tab".

By selecting "Current tab," you're telling Webflow not to include the `target="_blank"` attribute in the HTML output, which prevents the link from opening in a new tab.

However, please note that when you remove the `target="_blank"` attribute, the email link will no longer open a new email compose window. Instead, it will redirect the user to their default email client. If a user doesn't have a default email client set up, clicking the link might not have any action.

If you want the email link to behave differently, such as opening a new email compose window without a new tab, you'll need to use custom code.

Here's an example of how you can achieve this using HTML and JavaScript:

1. Remove the existing link from the image element in Webflow.
2. Give the image element a unique class name by adding a class under the "Class" section in the right panel.
3. Add a custom embed element to your Webflow canvas by dragging it from the "Add" panel or using the keyboard shortcut CMD/CTRL + E.
4. Inside the custom embed element, add the following code:

```html

```

Make sure to replace `.your-custom-class-name` with the actual class name you assigned to your image element.

This JavaScript code listens for a click event on the image element and prevents the default behavior. Then, it constructs a `mailto` URL with the desired subject and body, and opens it in a new tab using `window.open()`.

By using this custom code approach, you have more control over the email link behavior and can achieve the desired result without relying on the `target="_blank"` attribute.

Rate this answer

Other Webflow Questions