如果尚未打开,请打开新选项卡

时间:2018-05-22 14:30:18

标签: javascript

$('#cptagswrap').click(function() {
    window.open('tags.php');
});

这将打开一个新的浏览器标签并加载tags.php

我首先需要检查tags.php是否已经打开过。

  • 如果是,则转到标签而不打开新标签。
  • 如果不是,请打开它。

类似的东西:

if (tags.php).is(':open') {goto tags.php;}
else {window.open('tags.php');}

任何帮助?

1 个答案:

答案 0 :(得分:0)

从@Amy所说的文件中复制:

var windowObjectReference = null; // global variable

function openFFPromotionPopup() {
  if(windowObjectReference == null || windowObjectReference.closed)
  /* if the pointer to the window object in memory does not exist
     or if such pointer exists but the window was closed */

  {
    windowObjectReference = window.open("http://www.spreadfirefox.com/",
   "PromoteFirefoxWindowName", "resizable,scrollbars,status");
    /* then create it. The new window will be created and
       will be brought on top of any other window. */
  }
  else
  {
    windowObjectReference.focus();
    /* else the window reference must exist and the window
       is not closed; therefore, we can bring it back on top of any other
       window with the focus() method. There would be no need to re-create
       the window or to reload the referenced resource. */
  };
}