Open links in a new tab

Is Opening Links in new Tabs is not supported in the write.as Markdown?

Usually, If you still want to open links in new Tabs, you can then use the following code for your links:

[link](url){:target="_blank"}

Hi @zorbazelda! At the moment it is not supported in the current Write.as Markdown. Iā€™d recommend using HTML instead:

<a href="http://example.com/" target="_blank">Hello, world!</a>

If you wanted to get more technical, you could add Custom JS to your site (if you have a Write.as Pro subscription) that would make each link on your blog open in a new tab. That way you could use Markdown normally and not have to use the above HTML. That JS would look something like this:

var links = document.links;

for (var i = 0, linksLength = links.length; i < linksLength; i++) {
   if (links[i].hostname != window.location.hostname) {
       links[i].target = '_blank';
   } 
}

But the you mention would be a perfect suggestion to put in this topic where we are exploring different Markdown standards/options to implement in Write.as. Thanks for bringing this up and hope this answers your question!

4 Likes

Not exactly on the topic, but quite close:

Is it possible to use several javascript strings on the same time? For example, use the above code to open links on new tab, plus some code for the ā€œBack to topā€ link or footer icons or anything else that would require javascript?

Yes @koulaxizis, you can add multiple functions in the Custom JavaScript section of your blog. That one bit of code above is completely enclosed, so you can then add a function below that which adds the ā€œBack to topā€ link or footer icons. Itā€™s flexible in that way!

Thanks for this.

1 Like

@cjeller1592 Thanks for the JS above. Is it possible to make external links open in a new tab but open internal links in the same tab?

By ā€˜internal linksā€™, I mean when I link to another page on my blog.

Iā€™d appreciate your help if the above is possible.

1 Like

Should do this via the IF statement above - checks the hostname of the link and if different from the web domain hostname adds the target attribute.

Are there any updates to this?

It would be a huge help to just add an ā€œopen in a new tabā€ checkbox to this modal.
image

2 Likes

It would be absolutley great to have this feature (checkbox or markdown update)!

Thanks for the code. This is what I was looking for.

Loren