Chrome会在新窗口中打开链接列表而不是标签吗?

时间:2014-07-27 19:18:36

标签: javascript jquery html

我为自己构建了一个自定义初始页面,而我遇到的一个问题是,我希望在所有部分之上都有一个链接,点击该链接后,将打开新标签页中的所有页面。我已经通过列表进行了解析,但只有第一个链接在新选项卡中打开,所有其他链接在新窗口中打开。

以下是我正在处理的页面的链接:
https://dl.dropboxusercontent.com/u/114859/code-experiments/start-tab.html

以下是示例部分的HTML代码段:

<section>
  <h2>Wallpaper Sites (<a href="#">open all</a>)</h2>
  <ul>
    <li><a href="http://wall.alphacoders.com/">Alpha Coders</a></li>
    <li><a href="http://interfacelift.com/">InterfaceLIFT</a></li>
    <li><a href="http://thepaperwall.com/">The Paper Wall</a></li>
  <ul>
</section>

这里是JavaScript(主要是jQuery):

$( 'h2 a' ).on( 'click', function ( event ) {
  event.preventDefault();
  event.stopPropagation();
  $( this ).parent().next().find( 'a' ).each( function () {
    // console.log( this.href );
    window.open( this.href );
    window.focus();
  });
});

1 个答案:

答案 0 :(得分:1)

我不确定这种行为是否依赖于您/用户的Google Chrome设置。