Blank links opens in the same window - Why, and how to fix it? [closed]

谁说我不能喝 提交于 2019-12-10 15:12:03

问题


I have four links:

<a href="http://google.com" target="_blank">Google</a>
<a href="http://bing.com" target="_blank">Bing</a>
<a href="http://yahoo.com" target="_blank">Yahoo</a>
<a href="http://wikipedia.com" target="_blank">wiki</a>

When I click on a link, it will opens in a new window. And on click to another link, it will opens in the same window opened last time.

It is not good for me, I want to open a blank window on every single click, regardless of the opened windows.

How can I handle this? (I don't care about double-click Google link opens it twice, doesn't matter.)

And this is works, just it have to.

EXCUSE ME, communication problem with my PHP beast.

So, actually the links are like:

<a href="javascript:;" onclick = "window.open('http://google.com','Admin');">gaagle</a>
<a href="javascript:;" onclick = "window.open('http://bing.com','Admin');">bang</a>
<a href="javascript:;" onclick = "window.open('http://yahoo.com','Admin');">yahuu!</a>

And now, all the stuffs opens to the same window, because of the name tag (2nd param of window.open) -.- And since all the opened window's ID was Admin, every other windows opened on that window. I did not checked it, excuse me for wasting your time.


回答1:


If you give each link a different target, they will open in different tabs / windows.

<a href="http://google.com" target="googleWindow">Google</a>
<a href="http://bing.com" target="bingWindow">Bing</a>
<a href="http://yahoo.com" target="yahooWindow">Yahoo</a>
<a href="http://wikipedia.com" target="wikiWindow">wiki</a>

If you click a second time on a link, it will re-use the existing window if it is still available.

If you use target="_blank" every click should be in a new tab / window, regardless of previous clicks. If you aren't getting this behaviour, what browser are you using?

If you want all clicks to goto the same window use...

<a href="http://google.com" target="myWindow">Google</a>
<a href="http://bing.com" target="myWindow">Bing</a>
<a href="http://yahoo.com" target="myWindow">Yahoo</a>
<a href="http://wikipedia.com" target="myWindow">wiki</a>


来源:https://stackoverflow.com/questions/7952847/blank-links-opens-in-the-same-window-why-and-how-to-fix-it

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