在新选项卡中打开链接,仅打开新选项卡

Cam*_*ore 2 html javascript usability

我需要打开一个新的选项卡或弹出窗口,然后在单击原始源链接的任何其他时间,它会更新已打开的选项卡或窗口.现在它只是不断打开一个新选项卡,这不是预期的行为.

Ry-*_*Ry- 5

指定自定义target名称:

<a href="something.html" target="otherpage">Go to some page #1</a>
<a href="something2.html" target="otherpage">Go to some page #2</a>
Run Code Online (Sandbox Code Playgroud)

这将"命名"另一个窗口/选项卡,并target在该页面中打开与其相同的链接,或者在新窗口/选项卡中(如果尚不存在).window.open通过将名称指定为第二个参数,可以实现相同的效果.