# "פתח קישורים חיצוניים בלשונית חדשה כברירת מחדל" לא עובד

**URL:** <https://meta.discourse.org/t/open-external-links-in-a-new-tab-by-default-not-working/173344>\
**Category:** Product Support\
**Created:** [15 בדצמבר,‏ 2020,‏ 5:35am UTC](https://meta.discourse.org/t/open-external-links-in-a-new-tab-by-default-not-working/173344 "2020-12-15T05:35:19Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Bcat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bcat/32/163148_2.png) [@Bcat](https://meta.discourse.org/u/Bcat)\
**Post date:** [15 בדצמבר,‏ 2020,‏ 9:39am UTC](https://meta.discourse.org/t/open-external-links-in-a-new-tab-by-default-not-working/173344/10 "2020-12-15T09:39:20Z")

</div>

Instead of tweaking in settings I use this way

Demo: [Theme Creator](https://theme-creator.discourse.org/theme/Bcat/auto_link_new_tab)

```plaintext
<script type="text/discourse-plugin" version="0.8">
    api.onPageChange((url, title) => {
        // Automatically open external links in new tab or window
        var pc = 1;
        if ($("html").hasClass("mobile-device")) pc = 0;
        var links = document.links;
        for (var i = 0, linksLength = links.length; i < linksLength; i++) {
            if (links[i].hostname != window.location.hostname) {
                if (pc) links[i].target = '_blank'; else links[i].target = '_self';
            }
        }
    });
</script>

```

---

_[View the full topic](https://meta.discourse.org/t/open-external-links-in-a-new-tab-by-default-not-working/173344)._
