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!

2 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!