Add target=“_blank” in CSS

前端 未结 6 1876
闹比i
闹比i 2020-11-28 07:57

I have external links in top menu of my website. I want to open these links in new tab. I could achieve it using \"target=_blank\" in HTML. Is there a similar CSS p

6条回答
  •  情歌与酒
    2020-11-28 08:32

    While waiting for the adoption of CSS3 targeting…

    While waiting for the adoption of CSS3 targeting by the major browsers, one could run the following sed command once the (X)HTML has been created:

    sed -i 's|href="http|target="_blank" href="http|g' index.html
    

    It will add target="_blank" to all external hyperlinks. Variations are also possible.

    EDIT

    I use this at the end of the makefile which generates every web page on my site.

提交回复
热议问题