Open links in new window

Do you know I can set my external links to open in a new window?

1 Like

There is no such feature in markdown, however you can always use HTML inside markdown:

<a href="http://example.com/" target="_blank">example</a>

Juut add a target="_blank" attribute to your links (anchor tags). Now when your visitors click that link.

You may specify the window size by adding few javascript.

Example :

<a onclick="window.open(document.URL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');">
  Share Page
</a>

You could also add some javascript to make all external links open in a new tab automatically:

$('a').each(function() {
    var a = new RegExp('/' + window.location.host + '/');
    if(!a.test(this.href)) {
        $(this).click(function(event) {
            event.preventDefault();
            event.stopPropagation();
            window.open(this.href, '_blank');
        });
    }
});
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.