Opening links in a new tab and only the new tab

限于喜欢 提交于 2019-12-23 23:13:53

问题


I need to open a new tab or popup window, and then any other time the original source link is clicked, it updates the already open tab or window. Right now it just keeps opening a new tab and that's not the behavior that's expected.


回答1:


Specify a custom target name:

<a href="something.html" target="otherpage">Go to some page #1</a>
<a href="something2.html" target="otherpage">Go to some page #2</a>

This will "name" the other window/tab and open links with the same target in that page, or in a new window/tab if one doesn't already exist. You can achieve the same effect with window.open by specifying the name as the second argument.



来源:https://stackoverflow.com/questions/10132833/opening-links-in-a-new-tab-and-only-the-new-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!