<body>
XHTML: 
<a href="http://www.baidu.com"  rel="external">Baidu </a>  
</body>
<script type="text/javascript">
function externalLinks() { 
    if (!document.getElementsByTagName) return;  
     var anchors = document.getElementsByTagName("a");
     for (var i=0; i <anchors.length; i++) {  
     var anchoLink = anchors[i];  
     if (anchoLink.getAttribute("href") && anchoLink.getAttribute("rel") == "external"){ 
          anchoLink.target="_blank"   }  
    }  
}
 window.onload = externalLinks(); 
</script>
</html>

等价于 属性 target="_blank"
rel,这个属性用来说明链接和包含此链接页面的关系,以及链接打开的目标。动态改变链接打开方式

运用于 link标签和a标签中

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-09-14
猜你喜欢
  • 2021-08-08
  • 2021-11-28
  • 2021-10-22
  • 2021-12-10
  • 2021-05-27
  • 2022-12-23
相关资源
相似解决方案