markdown link opening in new tab

后端 未结 4 726
孤城傲影
孤城傲影 2021-02-03 20:00

Is there a way to open the below markdown link in new tab? I\'ve got some result from markdown target=“_blank”, but in my case it\'s different have used <>

4条回答
  •  独厮守ぢ
    2021-02-03 20:33

    If you have access to JavaScript, you can run a simple script to handle this for you wherever your markdown is rendered:

    const anchors = document.querySelectorAll('a');
    anchors.forEach((a) => {
      a.setAttribute('target', '__blank');
      a.setAttribute('rel', 'noopener noreferrer');
    });
    

提交回复
热议问题