通过Javascript在外部窗口中打开链接
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过Javascript在外部窗口中打开链接相关的知识,希望对你有一定的参考价值。
Rather than using target="_blank", which is deprecated by the W3C in Xhtml, you should use rel="external" for links that you want to pop out in a new window. This is the javascript that makes it happen.
function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; } } window.onload = externalLinks;
以上是关于通过Javascript在外部窗口中打开链接的主要内容,如果未能解决你的问题,请参考以下文章