# Option Open in the New/Same tab

**URL:** https://community.elfsight.com/t/option-open-in-the-new-same-tab/123948
**Category:** Social Media Icons
**Tags:** Gathering-Feedback
**Created:** [June 2, 2025, 9:54am UTC](https://community.elfsight.com/t/option-open-in-the-new-same-tab/123948 "2025-06-02T09:54:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Marc\_Fischer](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Marc\_Fischer](https://community.elfsight.com/u/Marc_Fischer)
#### Post date: [June 2, 2025, 9:54am UTC](https://community.elfsight.com/t/option-open-in-the-new-same-tab/123948/1 "2025-06-02T09:54:01Z")

</div>

Hello,

We would like to have the option **“Open in new tab"** for the social media icons, similar to how it’s implemented for buttons.

We also use the social media icons to link to pages within the same site. It’s a bit confusing for visitors when a new tab opens for an internal link.

Thank you in advance  
André

---

<div class="post-metadata">

### Author: ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)
#### Post date: [June 3, 2025, 10:20am UTC](https://community.elfsight.com/t/option-open-in-the-new-same-tab/123948/3 "2025-06-03T10:20:10Z")

</div>

Hi there and welcome to the Community, @Marc_Fischer 👋

Thanks for sharing your idea with us!

We agree that it would be awesome to have this option in the settings. If more users upvote this request, we’ll try to think it over in the future updates.

As for now, our devs prepared a special script to open links in the same tab:

```auto
const waitForElement = (selector, root = document, maxAttempts = 500) =>
  new Promise((resolve) => {
    let attempts = 0;
    const check = () => {
      const element = root.querySelector(selector);
      if (element) {
        resolve(element);
      } else if (attempts < maxAttempts) {
        attempts++;
        setTimeout(check, 100);
      }
    };
    check();
  });

function processSocialIcons(container) {
  container.querySelectorAll('a').forEach((link) => {
    if (link.getAttribute('target') === '_blank') {
      link.setAttribute('target', '_self');
    }
  });
}

function observeNewIcons() {
  const observer = new MutationObserver((mutations) => {
    mutations.forEach(({ addedNodes }) => {
      addedNodes.forEach((node) => {
        if (node.nodeType !== Node.ELEMENT_NODE) return;
        if (node.matches && node.matches('.eapps-social-icons')) {
          processSocialIcons(node);
        } else {
          const nested = node.querySelector && node.querySelector('.eapps-social-icons');
          if (nested) {
            processSocialIcons(nested);
          }
        }
      });
    });
  });
  observer.observe(document.body, {
    childList: true,
    subtree: true,
  });
}

waitForElement('.eapps-social-icons').then(() => {
  document.querySelectorAll('.eapps-social-icons').forEach(processSocialIcons);
  observeNewIcons();
});

```

  

This script should be added to the Custom JS field on the Style tab of your widget’s settings 🙂
