Is it possible?
So I have a link:
<a href='/page.htm' target='_blank'>
If they click it twice, it will load up two blank tabs. Is there anyway to get this particular link to load in the same new tab each time?
I would use window.open to reuse window if opened, you can see this answer for further details:
You can assign an onclick
handler to the anchor that calls the open
method of the window object. The first time the anchor is clicked, it opens a new browsing tab.
Notice the second parameter to the open
method (i.e., "other-window"). This is a handle to the new tab. If you want to load new content into that tab (instead of opening yet another tab), just call the open
method again with that same handle as the second parameter:
(function () {
var childWindowOpen = false;
window.onload = function (event) {
var anchor = document.getElementById("child-window-link");
anchor.onclick = function (event) {
var childWindow;
if (!childWindowOpen) {
childWindow = window.open("otherpage.html", "other-window");
} else {
childWindow = window.open("yetanotherpage.html", "other-window");
}
childWindowOpen = true;
return false;
}
};
}());