I am trying to reuse the same tab when clicking on links in my page. The links are grabbed dynamically from the database. I have tried the window.open("$LinkURL", "MyTab");
assuming that the $LinkURL
is the varriable with the link I want to open. But when a link is clicked, it opens in a new tab each time.
What I have noticed is that I can get my Tab to be reused if the new tab was still loading. But, once loaded I get a new tab opened and then have 2 tabs. the second thing is that if I use (http://www.google.com/) as the URL to open instead of the $LinkURL
varriable it works as expected and I am able to reuse the same Tab each time I click a new link. Here is a sample of the code I am using:
function newwin (urllink) {
newwindow = window.open( urllink ,'newwin');
//this is for closing the tab after some seconds, but i deactivate it for now
//window.setInterval(function(){window.newwindow.close()},10500);
}
<a href="javascript:newwin(\''.trim($CvITem_referal_link).'\');" id="LinkId_'.$J.'">
<img src="game/castleville/image/'.$ItemInfo_cat_img.'" name="'.$ItemInfo_cat_type.'" />
</a>