remove the "_blank" from links in social network widget icons

DavidL
DavidL Member Posts: 13

I'd like my links on the social networks widget icons to open in the same window.
On the widget you enter the URL but you can't choose to open in a new window.
Thanks for your help

Best Answers

  • Shawn
    Shawn Member Posts: 9 Marketing Team
    Answer ✓

    Hey DavidL! First, I'd really recommend submitting the ability to open social media links in the same window to the Idea Board. In the meantime, though, here's a hacky solution you can do today using JavaScript.

    1. Right click on your widget and select "Edit HTML/CSS"
    2. Press the "Dev Mode" button
    3. Directly beneath the "<span>" element that represents the social widget, paste the following code: <script> $('div.socialHubInnerDiv').find('a').removeAttr('target'); </script>
    4. Save, then preview.

    This uses javascript to delete the "target" attribute from every link within every social widget on the page. It'll look something like this:

    Hope that helps!

  • Thomas_Connery
    Thomas_Connery Member Posts: 218 MVP
    Answer ✓

    Nice Shawn!

Answers

  • Thomas_Connery
    Thomas_Connery Member Posts: 218 MVP

    It looks like you can edit the HTML to just add target="_blank" into the code. This should force a new tab to open for you on any social link.

  • DavidL
    DavidL Member Posts: 13

    Thank you for your help, but in my case it's the Universe that I want because by default the link opens in a new window.
    I've tried adding target="_self" it but it doesn't work.

  • Thomas_Connery
    Thomas_Connery Member Posts: 218 MVP

    Ahh, sorry about that. I misunderstood. It looks like the widget may not be able to do this without additional javascript. You basically need to execute window.open("https://[social url]", "_self"); but the social url changes of course so would need to be a variable.
    Because this is a locked Duda widget, I'm not sure if you can find a way around this. You may want to reach out to a Duda Expert who is certified in development. Or it's very possible someone else in the community may know a workaround. Good luck!

  • DavidL
    DavidL Member Posts: 13
    edited December 2023

    Thank you Shawn and Thomas for your help and very clear and detailed explanation, I will add my request on your idea board.