防止 linkedin 和 twitter 共享在同一个 window 中打开

Prevent linked-in and tiwtter share to open in the same window

我使用相同的代码(高度参数除外)打开链接和推特分享windows

window.open(
        url,
        title,
        '_blank,directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,=no,width='
        + width + ', height=' + height + ', left=' + x + ',top=' + y
    );

但它们是相互替换的,并不是分开打开的windows。 我如何在不同的 windows.

中打开它们

window.open() 函数的第二个参数为正在打开的 window 指定了一个名称。如果您使用与现有 window 相同的名称,则会重新使用 window。您从 title 变量中设置了该参数,因此请确保您的 title 对于您的 Twitter 和 Linked-in windows 不同 然后他们'将单独打开 windows.

(如果你每次都想要一个新的 window 然后将第二个参数设置为 "_blank"。)

进一步阅读:MDN's window.open() page