-
Aug092011
WordPress 外部链接在新窗口打开的方法
使用 jQuery 使 WordPress 外部链接在新窗口打开 $("a[href*='http://']:not([href*='"+location.hostname+"']),[href*='https://']:not([href*='"+location.hostname+"'])") .addClass("external") .attr("target","_blank"); 上述代码是给链接标签增加一个 target 属性,并且给他赋值为 _blank,这种代码是标准的,并且所有的外部链接都会在新窗口打开。好处是简单易用,不需要插件。 阅读全文2条评论